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 trialRAJ PATEL
4,282 PointsCan 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?
1 Answer
limlim
1,366 PointsMaybe 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.
Farouk Charkas
1,957 PointsFarouk Charkas
1,957 PointsA class is a super-data type, the system saves a class for use. Just like it saves Integers and String etc.