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

Compiler Error

when ever i'm trying to see preview there is no preview in the output.html , there is no errors listed and there is always compiler error

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

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

  Console console=System.console();
    String firstName="Adrian";
    console.printf("My name is %s \n",firstName);
    console.printf("%s is learning to write java \n", firstName);
  }
}

2 Answers

Start with the line String firstName = "Adrian"; and input until the line console.printf(" "); Don't include all of the other lines of code or any of the brackets at the end. Try to see if that works because It is only asking for the main code, not the entire program like the workspace.

Matthew White
Matthew White
15,124 Points

Your codes syntax and logic is fine, however the import statement for the Console class isn't present. I would suggest adding import java.io.Console; before you declare the Name class.