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 trialChris Janowski
1,844 PointsWhat is a class?
I'm sure this is a dumb question and I apologize for that, but I just want to make sure I understand all the language terms.
myName: Variable String and int: Data types console.readLine: Method console: Object
What exactly is a class?
5 Answers
Mohsin Ayub
6,822 PointsA class is an extensible program-code-template for creating objects, providing initial values for state (member variables) and implementations of behavior (member functions, methods). As you just said that console: Object. So this console object is the instance of Java Standard Library Class Console. This class also contains the method readLine(). The object is already created by the instructor. The instructor set the name of the object to console so after creating the object you can access the public data members and methods of that class.
Tobias Edwards
14,458 PointsMight as well have a crack at it!
A class in Java is essential to the language, without it the code won't run (I think). A class is like a kitchen, and inside the kitchen is where you make the food. A class contains methods (functions inside classes), which are like the things you use to make the food.
Chris Janowski
1,844 PointsThank you for answering and using a metaphor, it made it very easy to understand.
Craig Dennis
Treehouse TeacherI find it easiest to think of it as a blueprint used to create objects.
hardikkumar patel
217 PointsClass is set Of Methods and Data Member like variables int,string etc.
Chris Janowski
1,844 PointsIs a class what stores the methods?
Tobias Edwards
14,458 PointsA 'method' is just another word for: a function inside a class.
Leonardo Anez
Courses Plus Student 313 PointsVery good answers!