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 trialKelvin Warui
Courses Plus Student 878 Pointsjava.lang.nullPointerException
Hi i have done the code challenge for the string formating using the printf() method and passed.I am trying to do the same on my netbeans ide but i have an exception called java.lang.nullPointerException.I have capitalize S in the keyword String and initialized it i dont see why am getting an exception.My code looks like this
public class Introductions {
public static void main(String[] args) {
Console console = System.console();
String name = "Kelvin";
console.printf("%s is my name ", name);
}
}
1 Answer
Florian Tönjes
Full Stack JavaScript Techdegree Graduate 50,856 PointsHi Kelvin,
the console is usually not working in IDEs. Use System.out instead.
public static void main(String[] args) {
String name = "Kelvin";
System.out.printf("%s is my name ", name);
}
Kind Regards, Florian
Kelvin Warui
Courses Plus Student 878 PointsKelvin Warui
Courses Plus Student 878 PointsThank you very much ,been scratching my head all day wondering what am missing