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 Objects (Retired) Meet Objects Welcome Back

aishwarya chudasma
aishwarya chudasma
399 Points

what does Integer.parseInt("30") actually do?. When we can directly initialize the age and compare.

What does Integer.parseInt() method do?

2 Answers

Jaxon Gonzales
Jaxon Gonzales
3,562 Points

Integer.parseInt is the way for the computer to turn a String value into an int data value.

For example:

String numberToBeParsed = ("15");
int parsedNumber = Integer.parseInt(numberToBeParsed);
console.printf("%s", parsedNumber);

This would give a result of 15.