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

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,558 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.