|
|||||
|
|
#1 |
|
|
I've ***umed that byte[] does equals with the content too, it's otherwise. e.g. byte[] testA = new byte[4]; testA[0] = 0; testA[1] = (byte)0xac; testA[2] = (byte)0xab; testA[3] = (byte)0xde; byte[] testB = new byte[4]; testB[0] = 0; testB[1] = (byte)0xac; testB[2] = (byte)0xab; testB[3] = (byte)0xde; System.out.println( testB.equals( testA ) ); prints "false" How do you compare byte[]? memcpy() .. kinda equvilant? ... Hopefully not writing my own. Thanks. |
|
|
#2 |
|
|
news:chgmvj$sfi$1@mawar.singnet.com.sg... > Hi, > > I've ***umed that byte[] does equals with the content too, it's otherwise. > e.g. > > byte[] testA = new byte[4]; > testA[0] = 0; > testA[1] = (byte)0xac; > testA[2] = (byte)0xab; > testA[3] = (byte)0xde; > > byte[] testB = new byte[4]; > testB[0] = 0; > testB[1] = (byte)0xac; > testB[2] = (byte)0xab; > testB[3] = (byte)0xde; > > System.out.println( testB.equals( testA ) ); > > prints "false" > > How do you compare byte[]? > memcpy() .. kinda equvilant? ... > > Hopefully not writing my own. Use java.util.Arrays.equals(). The java.util.Arrays cl*** has all sorts of methods that are useful when working with arrays. -- David Hilsee |