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 trialRonald Maldo
5,532 PointsI'm getting error upon compiling on eclipse but was successful running on the workspace of treehouse.
You have 7 tires left to solve: --------- Exception in thread "main" java.lang.NullPointerException at Prompter.promptForGuess(Prompter.java:19) at Prompter.play(Prompter.java:13) at Hangman.main(Hangman.java:6)
2 Answers
anil rahman
7,786 PointsIt's because in ide's like eclipse it doesn't like the console object. Change it to Scanner object for reading input and
System.out.print();
for doing print to console.
Can also do
System.out.printf();
which is equivalent to
console.printf();
To make a Scanner object its like this:
import java.util.Scanner;
Scanner s = new Scanner(System.in);
To use it for user input is like this:
String name = s.nextLine();
System.out.printf("Hello %s",name);
Ronald Maldo
5,532 PointsThank you. i thought import java.io.Console; the importing of package was already sufficient.