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

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
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

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.