Static
Static — makes a field, method, or class variable belong to the class itself, rather than to instances of the class.
public class Car {
private static int carCount = 0;
public Car() {
carCount++; // Increment the static car count for every new Car created
}
// Static method
public static int getCarCount() {
return carCount;
}
} Static members are shared across all instances of the class, allowing for values or functions common to every object.
Semantic portal