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 trialsyalih
16,468 Pointsboolean method
Hello, is the any disadvantage in this using with "()" or not in this lesson using with '()' but when I remove its work http://teamtreehouse.com/library/java-basics/perfecting-the-prototype/censoring-words-looping-until-the-value-passes
boolean isInvalidWord = ( noun.equalsIgnoreCase("dork") || noun.equalsIgnoreCase("jerk") );
boolean isInvalidWord = noun.equalsIgnoreCase("dork") || noun.equalsIgnoreCase("jerk");
1 Answer
Luciano Cassettai
Courses Plus Student 626 PointsHi Syalih,
In this case does not make any diference but some time you'll need the brackets for eg:
Is not the same if you make this in a variable integer int a = 2 + 4 / 3;
And if you make this
int a = (2+4)/3
the brackets Separate in terms like in math. In a case you use a boolean like you use it there is not difference BUT if you do this for eg: Boolean test = (false|| true) && (false);
In this case Boolean value will be FALSE. You have to learn Boolean algebra http://en.wikipedia.org/wiki/Boolean_algebra
I hope I helped!
best!,
p.d: Sorry my bad english haha
Luciano
David Clausen
11,403 PointsDavid Clausen
11,403 PointsThe first line using () in java is valid. You can test it with
boolean test = (false|| true);
So we need more code to see, if you can paste your code. Once pasted put ```Java next to each other (the key next to one) and close the code with ```.
```Java
CODE
PASTED
HERE
```
If I can help then.
EDIT: Also I went to your lesson and tried it out in workspaces with no issue. Lets see your code for sure. Sometimes when debugging something it good to print something out to test where it went wrong.
Example:
Here we will see it printed out before we get to any loops or checks, so you know 100% if its being evaluated correctly. It may turn out what you suspect the problem is, is very quite different and located somewhere else.