Hi, When comparing two strings, how do you say String 1 is NOT equal to String 2? And also, when using an if statement, what type of OR do you use if you have String 1 equals String 2 OR String 2 equals String 3? TIA. Kevin
The method String.equals(String) returns a boolean. So, if you have String1 and String2, it returns true if String1 equals String2, false if not. So, to do String1 not equal to String2, you could do: String1.equals(String2) == false For the OR: if ((String1.equals(String2)) | | (String2.equals(String3))) [This message has been edited by Matt Senecal (edited September 14, 2001).]
There's nothing more dangerous than a resourceful idiot. ---Dilbert
When comparing two strings, how do you say String 1 is NOT equal to String 2? if(!string1.equals(string2)) do this; what type of OR do you use if you have String 1 equals String 2 OR String 2 equals String 3 if(string1.equals(string2)| | string2.equals(string3)) do this;
Originally posted by kevin schmidt: Can I do this: if ((String1.equals(String2) == false) | | (String2.equals(String3) == false)) { ... }
u want to check if string1 is equal to string2 or string2 is equal to string3 so above code will not work as it checks if string1 is not equal to string2 or string2 is not equal to string3 seemy previous post
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
a bit of art, as a gift, the permaculture playing cards