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 Basics Getting Started with Java IO

public class Introductions error error 1 illegal start of expression

Why am i getting this error i tried this code in workspace with import java.io.console and it works fine but this right here doesn't

IO.java
// I have imported java.io.Console for you.  It is a variable called console

public class Introductions {

  public static void main(String[] args) {
    Console console = System.console();
    String firstName = console.readLine("What is your name?  ");
    console.printf("Hi, %s welcome to DineOUT\n", firstname);
    console.printf("You can access the food in the menu %s\n", firstname);
  }
}

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Alberry;

Welcome to Treehouse!

For the challenge you don't need to create a class or do anything that isn't being asked in the instructions. So, if it requests to read in some data with console.readLine, that is all you have to do.

Also, you are defining your variable as firstName and calling it with the string formatter as firstname. Variables in Java are case sensitive.

Happy coding,

Ken

Ken Alger
Ken Alger
Treehouse Teacher

Also, if you notice in the comments for the code challenge, a console has already been imported so we don't have to redo that.

Thank you so much for the help :)