I have created a package called MathArithmetic which will contain the four basic arithmetic operator classes, that will have a method inside to return the result when called for Addition, Subtraction, Division and Multiplication.
However, if I have multiple classes inside the package, then how can I use an import statement for all classes. For example, java.util.*; will import all classes and methods from java.util package.
Currently, each package contains:
package MathArithmetic
public class Addition {
public int addNumbers(int...numbers) {
int sum = 0;
for(int i : numbers)
sum += i;
return sum;
}
}
Essentially, I want to call MathArithmetic.*; to call the class for Addition, Subtraction, Multiplication and Division. My current issue is that I am calling MathArithmetic.Addition; MathArithmetic.Subtraction; [...]
Rather than calling MathArithmetic.*; instead. What is the best way to do this?
Secondly, each of the MathArithmetic classes such as:
package MathArithmetic
public class Addition {
}
Are all in separate files. If I put them all in one large file such as:
public class Addition {}
public class Subtraction {}
public class Division {}
public class Multiplication {}
Then, it will say that the class must be put in a separate file. Is it possible to have all these class files in one file, rather than four separate files?