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

I am having Exception Error All the time using Console object

i am trying to keep it up and try to run the program here and there, but i am getting error using IDE or text editor : java.lang.NullPointerException but it runs for the linux terminal and when i tried to do the task of firstName variable it give me the same exception error msg !!

Name.java
// I have setup a java.io.Console object for you named console
String firstName = "Hadi Ahmed";
System.console().printf("%s", firstName);

1 Answer

Steven Parker
Steven Parker
231,236 Points

There should not be any parentheses between "console" and ".printf"

Also, the instructions ask that the message printed should include " can code in Java!"

i tried to use it as a new object but it didn't work to, and i tried to use the exist object and also not working in the task !! String firstName = "Hadi Ahmed"; console.printf("YOUR NAME %s",firstName);

Wow !! now i got it, the output of console object is console data type, so i would work only on consoles

Steven Parker
Steven Parker
231,236 Points

You're still missing the part of the message with " can code in Java!"

Steven Parker
Steven Parker
231,236 Points

I don't quite understand that last comment, but if you got it to pass, good deal. :+1: