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 trialJana McKinnon
4,219 PointsFor getCategoryCounts, why do we have to create a map with an Integer object rather than a primitive type int?
The task is to create a function that makes a map with categories and the amount of times they're listed. I completed the challenge after changing my map to Map<String, Integer> rather than Map<String, int>
I thought autoboxing would convert a primitive type to an object? Does that not work for Maps?
It's not a dire question, I'm just curious, thanks!
1 Answer
Florian Tönjes
Full Stack JavaScript Techdegree Graduate 50,856 PointsHi Jana,
you cannot use primitive types for generic declarations like <String, Integer>. Check out this link for more information.
Kind Regards, Florian