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
2,507 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.