15
Conrad
2y

I need someone standing behind me 24/7 making sure I don't try to String == "test"
Just wasted half an hour wondering why nothing was happening

Comments
  • 0
    When you finaly learn that, you
    are going to have problems with
    if( string = "test" )

    One problem solved, another created :P
  • 1
    Rip java
  • 4
    that took me about 3-6 days to fix. through hours of stackoverflowing someone mentioned to use the .equals method instead and it blew my mind away, why the fuck would someone build that in java
  • 0
    @SukMikeHok its for the first time I agree with you :D
  • 0
    @Codex404 Every man must agree with mr Hok
  • 2
    @SukMikeHok @Codex404 From what I remember... it has something todo with == being a comparison for object states or something like that, not values and since String is essentially a char array... its not classified as a primitive data type in java. I stand to be corrected though.
  • 1
    == compares the objects in Java for non-primitive types. So for two strings, it compares the string objects, which is almost never ehat you want.

    FWIW, my IDE complains if i do == on strings.
  • 0
    are you still on java 6?
  • 0
    @YADU @InterferenceObj I know, but why? If I would do Java I would overwrite the default string to overwrite the operators.
  • 0
    @InterferenceObj @Codex404 it probably wasnt intentional... just a side effect of how the comparison for objects/non-primitive data types had to be
  • 1
    I just did it again. Kil me.
Add Comment