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?

neubert
  • 15,947
  • 24
  • 120
  • 212

1 Answers1

0

Try this.

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