Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,363 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,363 PointsGrigorij Schleifer
10,363 PointsCool!!!!
See you in the forum :)