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 trialfahad lashari
7,693 PointsI didn't use an 'if' statement but achieved basically the same result. Is an 'if' statement in this necessary? if so,why
boolean isInvalidWord; do { console.printf("That language is not allowed\n"); name = console.readLine("Please choose a different name: "); isInvalidWord = name.equalsIgnoreCase("dork") || name.equalsIgnoreCase("dick"); } while (isInvalidWord);
//it does the same thing
1 Answer
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 PointsDon't know, right or wrong, so just an opinion here
I tried to google here and there, couldn't find much ...
There is definitely no improvement in result, they will be same. The only thing that is considered is readability.
And for readability, there is one nice guide
https://google.github.io/styleguide/javaguide.html
Google Java Guide. you can read it if you want.
Other than that cannot say anything.
fahad lashari
7,693 PointsThanks!
Matthias NΓΆrr
8,614 PointsMatthias NΓΆrr
8,614 PointsCould you please post code like this:
https://teamtreehouse.com/community/posting-code-to-the-forum