How does one declare an array of classes in Java and then use methods of the class when calling upon the array?
Printable View
How does one declare an array of classes in Java and then use methods of the class when calling upon the array?
Do you mean somthing like this?
Code:public class Q{
public static void main(String[] args){
double d = 1.5;
Z[] z = {new Z()};
long l = z[0].round(d);
System.out.println(" The value of " + d + " rounded " + " = " + l);
}
}
class Z{
public long round(double d){return Math.round(d);}
}