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

Ravirayappan Chinnappan
PLUS
Ravirayappan Chinnappan
Courses Plus Student 11,293 Points

showing error on"import java.io.Console;"how can i overcome it.

bummer on import section stated as illegal start..

Name.java
// I have setup a java.io.Console object for you named console
import java.io.Console;
class Name
{
  public static void main(String args[])
  {
    Console console=Systemconsole();
    String firstName="Ted";
    console.printf("my name is:%s",firstName);
    console.printf("%s, is practising java");
  }
}

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! It's important in these challenges to take them very literally and try not to do anything they don't explicitly ask for. In the very first comment, they say that they've already set up and imported java.io.Console for you. This means you're trying to import it a second time, which will cause an error.

Also, they have not asked you to create a class nor have they asked you to set up a main function. Try the challenge again doing only the things they ask for.

Hope this helps, but let me know if you're still stuck! :sparkles:

Pranjal Agnihotri
Pranjal Agnihotri
4,187 Points

You can use System.out.printf() method it will pass all the test cases. Hope it helps!