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

Joel Lithgow
7,414 Pointsconsole.readLine(""); in Eclipse?
After starting the Java basics course I downloaded Eclipse to play around in and noticed that the console does not have the .readLine("") method. I am aware that the Treehouse videos imported the Console and stored it as console and in Eclipse I have imported the Scanner and named it "scan". I am wondering why/how to get the readLine.
This is my code: String response = scan.readLine("Hello world!");
1 Answer

bzfchen
6,484 PointsString response = scan.nextLine();
Then type the response in the console, assuming you constructed scan = new Scanner (System.in).
Joel Lithgow
7,414 PointsJoel Lithgow
7,414 PointsThank you but I am wondering how to have the console output a question and wait for a response instead of having two separate lines of code.