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

Java Java Basics Perfecting the Prototype Looping until the value passes

I don't understand what the comment of the top of this exericse means about java.io.Console?

I don't understand what I am supposed to do with the comment that was mentioned about a variable named console. Can someone help me out?

Example.java
// I have initialized a java.io.Console for you. It is in a variable named console.

String response;
boolean yesOrNo;

do{
  response = console.readLine("Do you understand do while loops?"); 
  //yesOrNo = (response.equalsIgnoreCase("no"));
  if( response.equalsIgnoreCase("yes") ) {
    System.exit(0);    
  }
} while( response.equalsIgnoreCase("No"));

Thanks so much!

1 Answer

The comment says that java.io.Console is defined in a variable named console. This means you can use console.readLine() instead of java.io.Console.readLine().

Allan Clark
Allan Clark
10,810 Points

Next time use the answer box so you can get those lovely lovey internet points ;)