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

Antone Bagnall
Antone Bagnall
6,744 Points

Anyone know why I'm getting an error here?

I keep getting an error for an "illegal start of expression"?

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

public class IO {

  public static void main(String[] args) {
  Console console = System.console();
    String firstName = console.readLine("What is your first name?  ");

2 Answers

I don't think you need to have the line, Console console = System.console(); as the question says you can just use the variable named console.

This means you don't need to create a class either.

Just add the line that answers the question - it doesn't need much more than,

String firstName = console.readLine("What is your first name?  ");
Rob Bridges
.a{fill-rule:evenodd;}techdegree seal-36
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 Points

Hey Antone,

For now I think the challenge just wants you to create the variable firstName and assign it to console.readLine(), which you did correctly.

There's already a console imported in by Craig, and there's no need to define a class, don't worry though, you'll get more practice with those later.