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

Android Build a Simple Android App (2014) Improving Our Code Simple Refactoring: Using a Class

Can someone explain how does it work that: you can use the class name as the data type for a variable?

i am just not able to get it conceptually. i only find it logic when having Data Types as being int, double, float, String etc. How can the class become a data type for a variable?

Farouk Charkas
Farouk Charkas
1,957 Points

A class is a super-data type, the system saves a class for use. Just like it saves Integers and String etc.

1 Answer

limlim
limlim
1,366 Points

Maybe a way to get it is to consider that those simple data types (int, double, float, String) are actually themselves classes except they have been simplified for use.

In essence everything is a class, but we use some classes very often so much they have been simplified so we don't have to go through constructing them each time.