Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

String with Relational Operators in Java?

Name: Anonymous 2007-01-18 21:52

None of these end up as true when I enter "yes", "y", or "Y". I've tried entering them with and without quotes. What am I doing wrong?

      System.out.println("yes/no");
      //get answer
      getDirections = in.nextLine();
      if (getDirections == "yes"){
          game.printDirections();
      }
      if (getDirections == "y"){
          game.printDirections();
      }
      if (getDirections == "Y"){
          game.printDirections();
      }

Name: Anonymous 2007-01-19 5:15

Three comments:
1. Java fails for not being able to overload operators (because shit.equals(crap) is so much clearer and more maintainable that shit == crap, not to mention the inherent symmetry of == is not reflected, and thanks for making my objects less useful than built-in objects, oh, wait, int is not an object? Lol, what a failure of a language).
2. Java would fail even if it supported operator overloading.
3. I hate how Berkeley hippies and similar people fuck you in the ass when you want to do anything caseless. "equalsIgnoreCase"? My god, I bet they chose that name on purpose, to piss off people who prefers offering a decent, caseless behaviour to their users. If I made that API, just to piss hippies off, caseless string comparison would be eq, and case-sensitive comparison would be equalsCompareUsingCaseSensitiveMatching.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List