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

Why do primitives need Wrapper Types to use methods but object data types don't?

Thanks in advance.

1 Answer

An object is similar to a real-life object - it Has things and Does things. It was invented in programming because it is modeling the real life objects. For example, in real life, a car object has a manufacturer, release date, horsepower attributes, and it can accelerate, slow down, or blow the horn.

In programming, we can put any number of fields and attributes which will be owned by the object, and we can declare any number of methods which the object will be able to do - so that we are creating a similar structure as of a real life object.

A primitive datatype is descending from the early age of programming, when the idea of objects were not invented yet. The primitive datatypes are just plain variables, which cointain some type of data - text, number... etc.