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!

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 classes and objects

i couldn't understand how to make classes and objects in java and what both of them mean.

1 Answer

Classes are blueprints of objects. Objects are created from these blueprints(classes) and have states and behaviors. For example the class below

public class Person {
   public String firstName;
   public String lastName;

An object is an instace of a class. For example we can create a object called person1 from the Person class.

Person person1 = new Person();

Then we can change the properties which are public.

Person1.firstName =Kyle;

The class we created is called Person and we instantiated a object from that class called person1. You can istansiate multiple objects of the same class.

You can find more information here


Hope this helps.