How to create a Java class in Eclipse

creating a Java class in Eclipse and difference between class and object.

What is a class? It's something like a blueprint, or a template from which objects are created. Whereas an object is an instance, that has been created from the class.

Let's see an example. In this example the class has a name Person, which has attributes name and height. On the other hand, there are three objects aka instances of this Person class. These objects are: Michael with height 180cm, Josh with height 170cm and Amanda with height 170cm.

Let's create this example in Eclipse.

First we have to create a new Java project. Let's call it Persons. Next we will create a class Person in package persons. This person will have two attributes: name and height. Set them public visibility. It is easier for now. In next video I'll explain visibility modifiers and change the visibility of these attributes. We'll also create a method with name print, which will print name and height of a person.

Next we'll create a Main class with main method. In this method we'll create three persons, Michael with height 180 cm, Josh with 170 cm and Amanda with 170 cm. On each person we'll call method print, which will print their attributes to console.