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

Dylan Carter
4,780 PointsInteger and Int....?
I'm a little confused on the difference between the two. From my understanding the int just holds a number while Integer can manipulate the number also. So, why would you ever just use int when you could use Integer always and have the option to manipulate if you found out later that was needed?

Dylan Carter
4,780 Pointsbut he was saying in the video the difference between the two as far as java is concerned...
1 Answer

ALBERT QERIMI
49,872 PointsInteger refers to wrapper type in Java whereas int is a primitive type. Everything except primitive data types in Java is implemented just as objects that implies Java is a highly qualified pure object-oriented progamming language. If you need, all primitives types are also available as wrapper types in Java. in Java, the 'int' type is a primitive , whereas the 'Integer' type is an object.

Dylan Carter
4,780 Pointsbeing totally new I still don't fully get that concept but you explained it a little better so thank you, im sure itll make more sense in time.

Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 PointsHi Dylan, Albert is right, it's just a wrapper that exposes internal that can be cast on int objects, I think in this course we use the method parseInt method that is available to the Integer class to turn a string value into an int.
So let's say we were accepting input from a user, and our program was set up to take the value first in string forum. Something like below
Console console = System.console();
String myString = console.readLine("Please enter a number");
int myIntFromString = Integer.parseInt(myString);
Esentially all this is doing is taking our value that used to be a String and turning that value into an integer, we couldn't do this with int because it's a primitive type and not a built in wrapper class like Integer is.
You'll see similar things happen with Character the wrapper class for char if you want to expand what we've said a bit more.
Or Boolean and boolean.
Thanks, hope this expanded a bit.
ALBERT QERIMI
49,872 PointsALBERT QERIMI
49,872 Pointsint is just short for integer