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

The compiler said I got an error on line 4 and I have no idea how to fix

The compiler said I got an error on line 4 and I have no idea how to fix

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 = "Phuc";

    console.printf("Hello, my name is %s\n", firstName);
    console.printf("%s is learning how to write in Java\n", firstName);
                   }
                   }

2 Answers

Fahad Mutair
Fahad Mutair
10,359 Points

in 1st line he said

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

since you don't have syntax error in your code, and as he said you don't have to declare class name and main method just remove those

public class Name {
public static void main(String[] args) {

thank you it worked eventually

Emilio Sebastian
Emilio Sebastian
643 Points

erase everything and just let ------------------------------->

String firstName = "Phuc";

console.printf("Hello, my name is %s\n", firstName);
console.printf("%s is learning how to write in Java\n", firstName);

thank you, I appreciate