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 trialaishwarya chudasma
399 Pointswhat 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
3,562 PointsInteger.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.
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 PointsCraig's words:
it will take a string, whatever is in the string and turn it into a number so that we could use it.
Check info about it at tutorials point :
http://www.tutorialspoint.com/java/number_parseint.htm
and here is official docs:
https://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html#parseInt(java.lang.String)