When you create a class, you are making a blueprint that tells the computer what properties (fields) an object will have and what actions (methods) it can perform. For example, consider a simple class called Vehicle. In this class you can include common properties like the color and the year, and a method that tells you when the vehicle starts. Look at this code:
public class Vehicle {
public String color; // Vehicle color
public int year; // Production year
// Constructor: special method to initialize a new Vehicle
public Vehicle(String color, int year) {
this.color = color; // 'this.color' means the field in this object.
this.year = year;
}
// A method that simulates starting the vehicle.
public void start() {
System.out.println("The vehicle is starting.");
}
}