-1

I really don't understand what's wrong right now.

String s = "a,b,c,d";
String[] test = s.split(",");
System.out.println(test[0]);
System.out.println(test[0] == "a");

Console prints:

a
false

That doesn't make sense at all. test[0] is "a" and ("a" == "a") is false ?

Excuse me for my bad english. Thanks!

larsklaus
  • 31
  • 5

1 Answers1

0

== tests for reference equality.

.equals() tests for value equality.

Look this question.

Community
  • 1
  • 1
Semih Eker
  • 2,389
  • 1
  • 20
  • 29