get1()
method returns an array. I do get the output but the value from get1()
is [D@addbf1
My question is there any way to directly use the returned array to get the values in inf1[0]
and inf1[1]
and show it in the output statement?
I am aware of other ways of showing the output. But I want to know whether I can directly retrieve elements of the returned array.
class vehicle{
double [] inf1 = new double[2];
void set(double d, double s) {
inf1[0]=d;
inf1[1]=s;
}
double[] get1() {
return inf1;
}
}
public class calc2 {
public static void main(String args[]) {
vehicle ob = new vehicle();
ob.set(56.24, 75);
System.out.println("The time taken to cover "+ob.get1());
}
}