Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMoshe Sabaah
633 PointsWhen he creates the variable isInvalidWord would it not be the same to make the variable into a String and not a boolean
Whats the difference? What is the boolean giving us that a String isn't?
1 Answer
Benjamin Schmiedel
3,160 Points- a boolean can only have two values "true" and "false"
- a string can have infinit values (there a so many words you can build with chars)
conditions (if) use the simple way a boolean works. if the word (jerk) equals the word we would like to filter, then the boolean will be true
if(nome.equalsIgnoreCase("jerk"))
because of this the if statement will work. if statements couldn't work with strings
if("true"){code block}
would be invalid