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 trialHadi Ahmed
Courses Plus Student 620 PointsI 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 !!
// 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
231,184 PointsThere should not be any parentheses between "console
" and ".printf
"
Also, the instructions ask that the message printed should include " can code in Java!"
Hadi Ahmed
Courses Plus Student 620 PointsHadi Ahmed
Courses Plus Student 620 Pointsi 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);
Hadi Ahmed
Courses Plus Student 620 PointsHadi Ahmed
Courses Plus Student 620 PointsWow !! now i got it, the output of console object is console data type, so i would work only on consoles
Steven Parker
231,184 PointsSteven Parker
231,184 PointsYou're still missing the part of the message with " can code in Java!"
Steven Parker
231,184 PointsSteven Parker
231,184 PointsI don't quite understand that last comment, but if you got it to pass, good deal.