Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Rick Garland
Rick Garland
2,738 Points

legal start expression public class Introduction

cant get code to compile

Name.java
//import java.io.Console;

public class Introductions {

    public static void main(String [] args ){
// I have setup a java.io.Console object for you named console
      Console console = System.console();
      String firstName = "Rick";
      console.printf("My name is %s\n, firstName");
      console.printf("%s is learning java\n, firstName");
    }
}

1 Answer

andren
andren
28,521 Points

For the basic Java challenges Treehouse takes care of most boilerplate code for you. Meaning that you don't have to create a class or a method or import the Console class.

You just have to enter the specific code that will accomplish the task you are presented with. Since the first task asks you to create a variable called firstName and to store your name in it that's all the code you have to enter.

Like this:

String firstName = "Rick";

That single line of code is enough to pass the first task.