Reputation: 163
Can anyone explain me this:
byte [] arr = "hello".getBytes();
Why
arr.equals("hello".getBytes())
or
arr==("hello".getBytes())
return false?
Upvotes: 2
Views: 165
Reputation: 2142
Hope this one helps: http://www.java-examples.com/compare-two-java-byte-arrays-example
I think that the equals method on the byte array object only checks for the same reference and not for actual content.
Upvotes: 2