A class, if designed properly, will provide a grouping of related data and common tasks. Rather than having arrays of primitives all over the place, classes allow us to keep various bits of associated information together.
A common example is a generic Person class...
Trying to keep a list of information about people together without classes will consist of several separate arrays of information:
String[] firstNames;
String[] lastNames;
int[] height;
int[] weight
Obviously, trying to keep these collections of data organized and synchronized will take a great deal of effort.
Compare that to using a Person class:
class Person {
String firstName;
String lastName;
int height;
int weight;
}
Then we only need to keep a single array up to date:
Person[] people;
Copyright © 2026 eLLeNow.com All Rights Reserved.