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 Strings, Variables, and Formatting

JavaTester.java:72: error: illegal start of expression import java.io.console; even if i comment out i still get

even if i comment out import statement i still get the error

Name.java
import java.io.console;

class abc {

  public static void main (String [ ] args) {


    string firstName = "Alok";

  system.out.println (firstname);

}
}// I have setup a java.io.Console object for you named console

1 Answer

andren
andren
28,558 Points

For the basic Java challenges you don't have to include any boilerplate code. In other words you don't need to create a class or method to hold your code, and you don't need to instantiate the console object yourself. All of that is done for you automatically by the challenge checker.

The only code you need to type is code that will accomplish the exact thing the challenge is asking for. Since the task only asks you to create a String variable to hold your name you only need one line of code to solve the task.

In other words the only code you need for the first task is this one:

String firstName = "Alok";

And during other parts of the challenge where you need to use methods from the console object you can do so without including the code to import it or anything like that.