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

steven galvis
9,120 Pointsif statement is not checking the or condition
When I run this if statement in the command line it is ignoring jerk so when it asked me for a noun and I enter jerk it does not execute the statement to exit.
java if (noun.equalsIgnoreCase("dork") ||
noun.equalsIgnoreCase("jerk")){
console.printf("That language is not allowed. Exiting. \n\n");
System.exit(0);
1 Answer

Grigorij Schleifer
10,365 PointsHi Steven,
this i s my code that I created in IntellyJ. Everething works fine. Can you paste the complete code ?
public class Words {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.println("Type a noun");
String input = s.nextLine();
if(input.equalsIgnoreCase("dork") || input.equalsIgnoreCase("jerk")) {
System.out.printf("Try another word, because %s is not allowed \n", input);
System.exit(0);
}
}
}

steven galvis
9,120 PointsHi Grigoriji, thanks for getting back to me it turns out my code was fine it appears the tree house editor was not updating my code so it was executing the previous lines of code. Thanks anyway!
Grigorij Schleifer
10,365 PointsGrigorij Schleifer
10,365 PointsCool!!!!
See you in the forum :)