One of the techniques in object-oriented programming is encapsulation. It concerns the hiding of data in a class and making this class available only through methods. In this way the chance of making accidental mistakes in changing values is minimized. Java allows you to control access to classes, methods, and fields via so-called access specifiers.
Java offers four access specifiers, listed below in decreasing accessibility:
public class Square
/* public class */
public x, y, size;
/* public instance variables */