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

Adam Brown
Adam Brown
1,893 Points

Integer.parseInt() use.

I understand why we need to change a string to an integer, but I don't fully grasp what the reasoning for this code is. What is the "Integer" part for in the beginning of this code?

1 Answer

Michael Hess
Michael Hess
24,512 Points

Hi Adam,

The Integer class, in Java, is something called a wrapper class. A wrapper takes a primitive data type such as an integer and wraps it in an object.

The Integer part is needed because we are using the Integer class -- parseInt() is a method that's part of the Integer class.

Here are some external resources that you may want to read:

Java Wrapper Classes chart

parseInt() Tutorial at Tutorials Point

Javadoc for Integer class

If you have any questions feel free to ask! Hope this helps!