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 IO

Abhinav Sharma
Abhinav Sharma
421 Points

this code is running perfectly on PC but showing error here

??

IO.java
// I have imported java.io.Console foimport java.io.Console;

Public class Is 
{ public static void main (String[] args)
{ Console console = System.console();
  String Name = console.readLine("enter your name?");
  console.printf("my name is %s" , Name);
}
}

2 Answers

When solving the challenges you must follow the instructions given. The task is to create a variable firstName, however, you used Name, which will not pass. In addition, console variable was already created and there is no need to created.

String firstName = console.readLine("Enter your name?");
 console.printf("my name is %s" , firstName);

Also when creating a variable, you should always follow Java naming conventions, a variable should always start with a lowercase.

Abhinav Sharma
Abhinav Sharma
421 Points

ya I got it only the code that is asked for, nothing else