What easier than comparing 2 one character strings?
807600Oct 17 2007 — edited Oct 18 2007What easier than comparing 2 one character strings?
But, I can't do it!
I've declared String t which prints out as "A".
if ( t=="A") doesn't give a true value.
If I declare a String initialized to "A", that doesn't fire either.
t.equals("A") gives a Null Pointer exception at runtime.
If I try to convert them to char, I'm told that a one character string can't be converted to char.
Those are only a small subset of the ways I've tried to test whether the input string is "A".
In any other language, this is the most trivial task one could ask it to do.
So, how is it done in Java?