0
System.out.println("test".getBytes() == "test".getBytes() ? "same" : "diff");
System.out.println("test".getBytes().equals("test".getBytes()) ? "same" : "diff");

In both of those lines diff is output. They're the same thing so shouldn't it be same that is output?

1
  • 1
    Use java.util.Arrays.equals("test".getBytes(), "test".getBytes()) Commented Feb 2, 2021 at 5:51

1 Answer 1

0

Try this.

System.out.println(Arrays.compare("test".getBytes(), "test".getBytes()) == 0 ? "same" : "diff");
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.