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

unable to submit my work

I don't know why is it showing errors. I have written down the code correct.

Name.java
import java.io.Console;
public class Introductions {

    public static void main(String[] args) {
        Console console = System.console();
        // Welcome to the Introductions program!  Your code goes below here

      String firstName="Neha";
      console.printf("My name is %s\n", firstName);
      console.printf("%s is my Name\n", firstName);

  }
}

2 Answers

A Y
A Y
1,761 Points

Neha,

I have tried your codes: String firstName = "Neha"; console.printf ("My name is %s\n", firstName); console.printf ("%s is my Name\n", firstName); And it works with my both lines printed your name as expected. I think because you wrote it twice and the compiler expected only one line may ended in an error.

Regards, Amir

Hi, it seems you have skipped ahead in terms of how one writes such a program. Also note the comment provided by TTH when you first open the challenge.

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

String firstName = "bob";
console.printf("%s can code in Java!", firstName);