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 Data Structures Exploring the Java Collection Framework Maps

Brian Bartholomew
Brian Bartholomew
1,741 Points

Why are we now using Integer instead of int?

Privious to this video if I wanted to create an integer I would declare it like so.

int  someInteger = 0;

But now we are doing

Integer  someInteger = 0;

Is it because of the object we are returning?

public Map<String, Integer> getSomeMap(){...}

1 Answer

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Yes, you cannot use primitives in Generic type declarations. So a wrapper class is used to autobox.