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

Java

Java errors in Workspace

I'm playing with the code to get more familiar with the syntax to understand the connections better. As I finish goofing around and try to see the results of my work I am hit with error alerts to my last columns of code.

Code Console

Help me understand what's wrong.

Thank you

4 Answers

Hi Francis!

Could you please display your code? Maybe I can figure out what your error is then.

Thanks! :)

sorry having a hard time finding out how to add the screenshot to the post lol

Just copy and paste the code in the forum post. Like so:

code

import 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);
  }

} }

The problem has something to do with the brackets

If 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!!! :)