As a rule of thumb, when you have a set of data with a specific structure and you want to perform specific methods on it , use a class. That is only valid, however, if you use multiple data structures in your code. If your whole code won’t ever deal with more than one structure.
Read moreWhat happens when we create a class in Java?
All objects in Java programs are created on heap memory. An object is created based on its class. You can consider a class as a blueprint, template, or a description how to create an object. When an object is created, memory is allocated to hold the object properties .
Read moreWhen should you make a new class in Java?
11.1 The Time Class A common reason to define a new class is to encapsulate related data in an object that can be treated as a single unit . That way, we can use objects as parameters and return values, rather than passing and returning multiple values.
Read more