beginner question--boolean expressions
Okay, say that I am using an if-else statement and i want to basically say that
if (string.contains("#")
then do this...
else if (string.contains ("#") = false)
then do this...
else
then do this...
so, my question is about the second else if statement. I know that I can't say what I typed up there but I need to figure out a way to write if string doesn't contain a certain substring then do something else... Any suggestions?
Re: beginner question--boolean expressions
Any reason a simple else clause won't work? As anything which doesn't evaulate to true when performing String.contains("#") will enter the else clause.
Re: beginner question--boolean expressions
You do not want the expression to equal true, so what's the opposite of true? A lot of these basics can be found at the following link:
Lesson: Language Basics (The Java™ Tutorials > Learning the Java Language)
Re: beginner question--boolean expressions
I tried both of these already and returned
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1931)
at tweetToLeet.main(tweetToLeet.java:26)
Re: beginner question--boolean expressions
And what code did you use exactly to achieve such an Exception?
Re: beginner question--boolean expressions
I figured it out... thanks for all the advise though... had nothing to do with my boolean expressions.... had more to do with placement of {'s.... stupid mistake haha :/
Re: beginner question--boolean expressions
Glad you solved it ninjaBob.
If you could now mark this thread as solved, I would be grateful.