I do not understand why these two programs do not give the same results
and each do not give the same results every time. They both give one general answer all the time and then all of a sudden they give a odd result. Maybe, I am not understanding how to do byte arrays in NetRexx or Java. In both versions I get [B@e53108 lots of times and then for some reasons I get [B@f62373 (Maybe OS or Java Bug; Using Sun Java on xubuntu 10.10) In the NetRexx version System.out.println and say always agree. From the code, are they not basically the same program? Java Program and Sample Outputs : public class Main { public void test() { byte[] SALT = new byte[20]; SALT[0]=(byte)(int)41; SALT[1]=(byte)(int)61; SALT[2]=(byte)(int)73; SALT[3]=(byte)(int)66; SALT[4]=(byte)(int)65; SALT[5]=(byte)(int)20; SALT[6]=(byte)(int)44; SALT[7]=(byte)(int)66; SALT[8]=(byte)(int)65; SALT[9]=(byte)(int)72; SALT[10]=(byte)(int)66; SALT[11]=(byte)(int)65; SALT[12]=(byte)(int)20; SALT[13]=(byte)(int)44; SALT[14]=(byte)(int)61; SALT[15]=(byte)(int)72; SALT[16]=(byte)(int)74; SALT[17]=(byte)(int)69; SALT[18]=(byte)(int)65; SALT[19]=(byte)(int)73; System.out.println(SALT); System.out.println(SALT[0]); System.out.println(SALT[1]); System.out.println(SALT[2]); System.out.println(SALT[3]); System.out.println(SALT[4]); System.out.println(SALT[5]); System.out.println(SALT[6]); System.out.println(SALT[7]); System.out.println(SALT[8]); System.out.println(SALT[9]); System.out.println(SALT[10]); System.out.println(SALT[11]); System.out.println(SALT[12]); System.out.println(SALT[13]); System.out.println(SALT[14]); System.out.println(SALT[15]); System.out.println(SALT[16]); System.out.println(SALT[17]); System.out.println(SALT[18]); System.out.println(SALT[19]); } public static void main(String[] args) { new Main().test(); } } Couple of sample outputs for Java: monroe@janitor:~/bugorhelp$ java Main [B@e53108 41 61 73 66 65 20 44 66 65 72 66 65 20 44 61 72 74 69 65 73 monroe@janitor:~/bugorhelp$ java Main [B@f62373 41 61 73 66 65 20 44 66 65 72 66 65 20 44 61 72 74 69 65 73 NetRexx Program and Sample Outputs : (Has extra System.out.println(SALT) statement) SALT = byte[] byte[20] SALT[0]=byte 41 SALT[1]=byte 61 SALT[2]=byte 73 SALT[3]=byte 66 SALT[4]=byte 65 SALT[5]=byte 20 SALT[6]=byte 44 SALT[7]=byte 66 SALT[8]=byte 65 SALT[9]=byte 72 SALT[10]=byte 66 SALT[11]=byte 65 SALT[12]=byte 20 SALT[13]=byte 44 SALT[14]=byte 61 SALT[15]=byte 72 SALT[16]=byte 74 SALT[17]=byte 69 SALT[18]=byte 65 SALT[19]=byte 73 System.out.println(SALT) say SALT say SALT[0] say SALT[1] say SALT[2] say SALT[3] say SALT[4] say SALT[5] say SALT[6] say SALT[7] say SALT[8] say SALT[9] say SALT[10] say SALT[11] say SALT[12] say SALT[13] say SALT[14] say SALT[15] say SALT[16] say SALT[17] say SALT[18] say SALT[19] Couple of sample outputs for NetRexx: monroe@janitor:~/bugorhelp$ java isalt [B@e53108 [B@e53108 41 61 73 66 65 20 44 66 65 72 66 65 20 44 61 72 74 69 65 73 monroe@janitor:~/bugorhelp$ java isalt [B@f62373 [B@f62373 41 61 73 66 65 20 44 66 65 72 66 65 20 44 61 72 74 69 65 73 _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Jason -
When you attempt to print an object that does not have a well defined string format, such as an entire array, the toString call is going to fall-back to the basic Object class toString method which generates a string based on the object type and the hashcode for the object. The type signature for a byte array is "[B" and here is what the docs for the Object hashCode method say: As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.) If I understand that correctly, the hex code portion of the output will depend on the memory location of the object which can change between runs. Hope that helps, -- Kermit On 11/10/2011 8:46 AM, Jason Monroe Martin wrote: I do not understand why these two programs do not give the same results _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
On 11/10/2011 04:46 PM, Kermit Kiser wrote: Jason - _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Free forum by Nabble | Edit this page |