I need to verify that a code generated in one class is same as code verified in another class. But the twist is in other class the logic used is different. Its like this.
Class A:
String = “0A2D” (suppose)
i used the substring method, take out 0A , 2D and convert them into Decimal values & store them as bytes.
the end result will look something like this
int a1 = (byte) Integer.parseInt(s,16); here s= 0A
int a2 = (byte) Integer.parseInt(s,16); here s= 2D
so a1 would be 10 ( 1byte memory) , a2 would be 45 (1byte memory)
Class B:
In this class i’m supposed to use the method getBytes(). But when i use that I see some strange o/p saying [B@…… Firstly I need information about what is happening there actually. How is it getting encoded. Secondly the o/p here should be an array of bytes matching with o/p of Class A. i.e
byte[] b = {a1a2} ( memory 2bytes)
b = {1045}
So at the end A would be having 2 values with 1byte each. But B would have an array which would have the same two values but the memory size would be 2bytes.
I hope I’m clear in my ques & didnt confuse.
your kind help would be appreciated. thanks in advance.
What line of code gives the output “[B@……”? (I assume the dots mean you truncated the output.) This particular output appears as if you are trying to print the array reference rather than the elements of the array. You should either use a for loop to print the individual elements or use Array.toString() to get a String representation of the array.