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 trialPatryk Sarnik
157 PointsException in thread "main" java.lang.NullPointerException at coding.treehouse.main(treehouse.java:11)
package coding;
import java.io.Console;
public class treehouse {
public static void main(String[] args) {
Console console = System.console();
String firstName = console.readLine("What's your name? ");
console.printf("Hello my name is %s\n", firstName);
}
}
1 Answer
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsI'm not 100% sure, but I've seen people have this error before using this System.console()
in their own IDE. I think the best solution is to do these exercises in the Treehouse workspace where this console is built into the environment.
Outside of Treehouse, there is more than one way of receiving input from the command line. I prefer the Scanner class.