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 Parsing Integers

Guys what code decides the warm age? because my console is working perfectly after I delete int age = 12;

Like I say on the question I technically have deleted good amount of lines of codes which I thought were the main part of the warning pg 13, but for some reason the console still responds like if the int age = 12; and if(age<13); were there. did I misinterpret the class of the teacher?

2 Answers

Hi Kerin,

going onwards please remember to paste your code when asking a question, will make answering those much easier.

I assume you have problem making age value based on user input, here is what needs to be done:

  1. Declare String variable and assign it's value to readLine method of Console class.
  2. Parse returned String to Integer value via parseInt method of Integer class.
  3. Use returned Integer in validation process (i.e. if < 13).

Of course I also assumed you have saved all changes and recompiled your classes.

Now, final piece of code should look like this:

String ageAsString = console.readLine("Enter your age: ");
int age = Integer.parseInt(ageAsString);
if (age < 13) {
 //your code here
}

Hope this helps, otherwise just please paste your code.

thank you!

If this helped please remember to mark my answer is accepted - thanks!