Java Java Basics Getting Started with Java Strings, Variables, and Formatting

Even with the correct code the compiler shows errors.

public class Name{

public static void main(String[] args)

{

System.out.println("My name is Srikanth");

}

}

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

public class Name{

  public static void main(String[] args)

  {

  System.out.println("My name is Srikanth");

  }  

  }

2 Answers

Jennifer Nordell
MOD
Jennifer Nordell
Treehouse Moderator

Hi there! It's important to note in these challenges to only do what they say to do. Even if your code compiles and runs outside the challenge, it does not mean it meets the requirements of the challenge. In your code, you've created a class and put in a main method which is what we would expect in a full program. But the challenge is not a full program.

The instructions for the first step are:

Define a string variable named firstName that stores your name. Set the value to your name.

Nowhere in your code have you (as of now) defined any variables. Try going back and only doing what it says to do. If it said something like "define an integer variable named x that stores the integer 9", I would write:

int x = 9;

Hope this helps! :sparkles:

I din't knew that. thanks a ton Jenifer.