0

I am working on a multiplayer game.. and i came up with a really weird situation.
It's even possible? -

System.out.println(foo);                    // left
System.out.println(foo instanceof String)  // true
System.out.println(foo == "left")         // false

I don't understand how it's even possible..

I really don't think it will be a good idea to post all of my code.
Any ideas why its like that? and how can i fix it?

Thanks in advance

julian
  • 4,634
  • 10
  • 42
  • 59

1 Answers1

0

You shouldn't compare Strings by == operator, use equals method instead.

Jakub H
  • 2,130
  • 9
  • 16