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

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

not working for me

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


public class Name {

    public static void main(String[] args) {

        String firstName = "Radhika";
      console.printf(" my name is %s " , firstName);


  }
}

1 Answer

andren
andren
28,558 Points

For the basic Java challenges Treehouse takes care of automatically inserting any code that is not directly related to the challenge, so all of the code to define the class and the main method and other such boilerplate code is not needed.

You only need to insert the code that performs the specific task the challenge is asking for. Since the challenge is asking you to assign your name to a variable called firstName that is all you have to do for this task. Like this:

String firstName = "Radhika";

No other code is needed to pass the first task.