Search code examples
javajakarta-eeencode

Why the value changed at each runtime in java using getbytes()..?


I just want to clarify something using of getbytes() in java, i am doing simple program in Java to encode the string using of getbytes(), but each run time the value should be change.. can anyone explain why its changing..?

Here my sample code :

  String m_a="Hello";

  byte[] b1 = m_a.getBytes();

output 1 :

            encoded value : [B@ffb35e

output 2 :

           encoded value : [B@fe0ce1

output 3 :

           encoded value : [B@ed3bff

How can i get the unique value of that string.


Solution

  • you're printing out the identifier for the object, not its content. if you print the actual bytes inside the array it should be the same every time