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
Francis Bernadel
365 PointsJava errors in Workspace
4 Answers
Aayush Mitra
24,904 PointsHi Francis!
Could you please display your code? Maybe I can figure out what your error is then.
Thanks! :)
Francis Bernadel
365 Pointssorry having a hard time finding out how to add the screenshot to the post lol
Aayush Mitra
24,904 PointsJust copy and paste the code in the forum post. Like so:
code
Francis Bernadel
365 Pointsimport java.io.Console;
public class Introductions {
public static void main(String[] args) {
Console console = System.console();
// Welcome to the Introductions program! Your code goes below here
String name = console.readLine("Hey.. Can you hear me... We don't have much time...\n Tell me, what is your name? ");
String choice;
boolean isInvalidWord;
do {
choice = console.readLine("%s... I see. Tell me something %s,\n Do you remember anything? ", name, name);
isInvalidWord = choice.equalsIgnoreCase("no");
if (isInvalidWord) {
console.printf("Hmmmmm... Are you sure you don't?\n\n");
} while (isInvalidWord);
}
} }
Francis Bernadel
365 PointsThe problem has something to do with the brackets
Aayush Mitra
24,904 PointsIf it has something to do with the brackets, here is the correct code:
public static void main(String[] args) {
Console console = System.console();
// Welcome to the Introductions program! Your code goes below here
String name = console.readLine("Hey.. Can you hear me... We don't have much time...\n Tell me, what is your name? ");
String choice;
boolean isInvalidWord;
do {
choice = console.readLine("%s... I see. Tell me something %s,\n Do you remember anything? ", name, name);
isInvalidWord = choice.equalsIgnoreCase("no");
if (isInvalidWord) {
console.printf("Hmmmmm... Are you sure you don't?\n\n");
}
} while (isInvalidWord);
}
You forgot the close bracket for the do statement.
Hope this helps!
If this does not work please let me know.
Thanks!!! :)