Computer Science Canada Strings HELP WANTED |
Author: | king [ Sat Nov 19, 2005 7:15 pm ] |
Post subject: | Strings HELP WANTED |
I am having trouble in loops how can i specify if one string does not equal the other i know how to specify if it equals eg str.equals (str2)); HOW CAN I MAKE IT NOT EQUAL!!!!!!!! |
Author: | Hikaru79 [ Sun Nov 20, 2005 12:03 am ] | ||||
Post subject: | |||||
The .equals(String s) method returns a boolean. So you can simply negate the entire expression. You do this by putting an exclamation mark in front.
Simple, no? ![]()
|
Author: | Hikaru79 [ Sun Nov 20, 2005 12:04 am ] |
Post subject: | |
Err, great. I accidently used a [/code] instead of [/syntax] and somebody has for some reason turned off editing in the help forums =/ I hope it's clear anyway. Why *has* editing been turned off? It's mighty useful. I make mistakes all the time ![]() |
Author: | DanShadow [ Tue Nov 22, 2005 1:42 pm ] | ||
Post subject: | |||
Your typing was a little eratic, but as I understand, your looking to find out if one string is NOT equal to another? Try this:
Hope that helps.- [PS] Hikaru is also correct, the exclamation mark signifies a NOT statement, which would determine whether or not something is equal to something else. The '^' does nealry the same thing, except it will check that both sides of the argument (name1,name2) are not equal, and if they are not, it will return true, if they are, it will return false. |
Author: | rizzix [ Wed Nov 23, 2005 12:34 pm ] | ||
Post subject: | |||
DanShadow wrote:
uhm... that's not proper Java.. What Hikaru said was right.. that's wrong. |