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
Tim Ott
2,249 PointsIssues with challenge in stage 3 of Java Basics.
The code challenge is "Add an if statement that checks to see if firstExample is equal to secondExample. If it is, pring out "first is equal to second".
I am unable to figure out how to do this form some reason. I have messed around with the code and haven't been able to find anything resembling the lesson through google.
Here is the code I have at the moment, I am still messing around with it.
// I have imported a java.io.Console for you, it is named console.
if (firstExample.equals(secondExample)) {
console.printf("first is equal to second. \n\n");
}
String firstExample = "hello";
String secondExample = "hello";
String thirdExample = "HELLO";
2 Answers
Tim Ott
2,249 PointsNever mind figured it out. I didn't realize the if statement needed to be after the Strings for some reason. Simple change :)
Craig Dennis
Treehouse TeacherHey Tim!
The reason for the ordering is because the variables need to be declared before you use them. Nice job figuring it out yourself!