Categories
Java Tutorials

Array as private data member inside a Java class, access by getter and setter methods

Data hiding concept, private data member of a Java class described with the help of a Java array, where an array declared as private member inside a Java class. So you cannot access the array elements inside Java class directly. You can insert integers in the array, delete array elements (which are integers) and get element from the array in Java with the help of getter and setter methods. Deletion of array element needs shifting of elements because it creates a vacancy inside array.  A practical example of data hiding w.r.t array as private data member inside a Java class.