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 trialchad geiger
186 PointsCant figure out this question
I cant figure out this question
// I have imported a java.io.Console for you, it is named console.
if (firstExample.equalsIgnoreCase("secondExample")){
console.printf("first is equal to second \n\n");
{
String firstExample = "hello";
String secondExample = "hello";
String thirdExample = "HELLO";
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHey Chad,
There are actually 3 errors here:
-
secondExample
cannot be in quotation marks. You are comparing the values inside the variables. Once you put quotes around it, you turn it into a string. So, it's comparing the first value to the literal "secondExample". - You have an opening curly instead of a closing one for the end of the
if
statement. - And very important... The
if
statement needs to come after the variable declarations. At the top, like you have now, theif
statement has no idea thefirstExample
or thesecondExample
variable even exist, so you would get a compiler error. In Java, and almost all languages, variables need to be declared before they can be used.
So, give it another go with these in mind. Once those are corrected, the code will pass. :)
Keep Coding!