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 trial

Java Java Basics Perfecting the Prototype Censoring Words - Looping Until the Value Passes

When I place the || symbol my code wont work.

Picked up _JAVA_OPTIONS: -Xmx128m
TreeStory.java:25: error: illegal start of expression
if (noun.equalsIgnoreCase("dork")) || noun.equalsIgnoreCase("jerk");
^
TreeStory.java:27: error: illegal start of expression
} while(noun.equalsIgnoreCase("dork")); || noun.equalsIgnoreCase("jerk");

Here is my code. do{ noun = console.readLine("Enter a noun: ");
if (noun.equalsIgnoreCase("dork")) || noun.equalsIgnoreCase("jerk"); console.printf("That language is not ok here young man. Get out bum \n\n"); } while(noun.equalsIgnoreCase("dork")); || noun.equalsIgnoreCase("jerk");

1 Answer

Stephen Gheysens
Stephen Gheysens
11,935 Points

Hi Bryan,

In the following line of code...

if (noun.equalsIgnoreCase("dork")) || noun.equalsIgnoreCase("jerk");

You have placed the closing parenthese for the if too soon - it needs to go after the second condition:

if (noun.equalsIgnoreCase("dork") || noun.equalsIgnoreCase("jerk"));

Additionally, I think you intend to have the console.printf statement inside of the if, like this:

if (noun.equalsIgnoreCase("dork") || noun.equalsIgnoreCase("jerk")) {
console.printf("That language is not ok here young man. Get out bum \n\n");
}

Let me know if this helps, and if you have any further questions!