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 trialJohn Paul Luna
1,624 Pointsprogram will not compile. It was verified on other compiler to work.
tried to complete quiz, tried various changes to code. copied code and pasted into other compiler as such:
import java.io.Console;
class Untitled {
public static void main(String[] args) {
Console console = System.console();
String firstExample = "hello";
String secondExample = "hello";
String thirdExample = "HELLO";
if (firstExample.equals( secondExample )) {
console.printf("first is equal to second");
System.exit(0); }
}
}
the program worked. I tried +/- curly braces to treehouse compiler to see if it would work-no avail.
best,
John
// I have imported a java.io.Console for you, it is named console.
String firstExample = "hello";
String secondExample = "hello";
String thirdExample = "HELLO";
if (firstExample.equals(secondExample)){
console.printf("first is equal to second");
System.exit(0);
}
}
2 Answers
anil rahman
7,786 PointsThis will work, plus in your pasted code you have an extra curly brace on bottom line
// I have imported a java.io.Console for you, it is named console.
String firstExample = "hello";
String secondExample = "hello";
String thirdExample = "HELLO";
if (firstExample.equals(secondExample)){
console.printf("first is equal to second");
}
if(firstExample.equalsIgnoreCase(thirdExample)){
console.printf("first and third are the same");
}
Craig Dennis
Treehouse TeacherTry to remove the System.exit, pretty sure you are exiting the challenge ;)