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 trialShehan Dissanayake
19,119 PointsNo errors! But doesn't run!
String noun = console.readLine("Enter a noun: ");
if(name.equals("dork")){
console.printf("That language is not allowed.Exiting.\n\n");
System.exit(0);
}
This does compile without error but doesn't execute the if condition when i type "dork" as the noun.
Thoughts?
4 Answers
Huzaifa Sajjad Malik
Courses Plus Student 10,823 PointsString noun=console.readLine("Enter a Noun : ");
if(noun.equals("dork"))
{
console.printf("This kind of lang is not allowed! Exiting \n\n");
System.exit(0);
}
The problem here is that you were getting the input in name but were checking the name element thats why it was not executing the way you expected
Pedro Cabral
Full Stack JavaScript Techdegree Student 23,916 PointsYou are giving 2 different var names: noun and name.
Shehan Dissanayake
19,119 Pointseven I put noun it doesn't work!
Pedro Cabral
Full Stack JavaScript Techdegree Student 23,916 PointsCan you please paste the absolutely full code?
Alan Hood
1,528 Pointsyou may have forgot to save before running.