You can have one single object inside main and add will be called using that which in turn difference . Note: You can also make add and difference as static so you do not need any object at all.
Read moreHow do you define a class in Java example?
To create an object of Main , specify the class name, followed by the object name, and use the keyword new :
Read moreWhy do we initialize objects in Java?
Initializing an object means storing data into the object . Let’s see a simple example where we are going to initialize the object through a reference variable. We can also create multiple objects and store information in it through reference variable.
Read moreHow do you define a class in Java example?
To create an object of Main , specify the class name, followed by the object name, and use the keyword new :
Read moreWhat are the 3 ways of object initialization?
3 ways to initialize an object in Java
Read moreHow do I find a class in Java?
Finding an Object’s Class in Java
Read moreHow do I find a class in Java?
Finding an Object’s Class in Java
Read more