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

I am confused, I am following the prompt, given the examples provided and it continues to say it is an illegal start

it says illegal start but when i added in the public class io, it doesnt work either?

IO.java
    public static void main(String[] args) {
        Console console = System.console();
        // Welcome to the Introductions program!  Your code goes below here
      String firstName = console.readLine("what is your name?");
      //thisIsAnExampleOfCamelCasing
        console.printf("Hello my name is %s\n", firstName);
      console.printf("%s is learning how to write java huwiria\n", firstName);
  }

1 Answer

John Sns
John Sns
4,193 Points

The instructor has already made a main function and they have already made a console variable. As it says in the first comment(Before you probably removed it). So, you shouldn't make 2 main functions and you shouldn't declare a variable 2 times.

//    public static void main(String[] args) {
//        Console console = System.console();
        // Welcome to the Introductions program!  Your code goes below here
      String firstName = console.readLine("what is your name?");
      //thisIsAnExampleOfCamelCasing
        console.printf("Hello my name is %s\n", firstName);
      console.printf("%s is learning how to write java huwiria\n", firstName);
 // }

I have commented out the parts you don't need. i.e they have already been added by the instructor behind the scenes.