I am unable a to understand a concept. double variable and double array are declared outside the function and a function which increments the value of both is made. Values from the functions are not returned still the value of the double array gets incremented where as it is not the same case with double variable. Why ? Same with Double class
double x = 100.5;
p.m1( x );
System.out.println("" + x);
double[] xa1 = {10,20,30,40};
//p.m5( xa1 );
for (int i=0;i<4;i++){
System.out.println(xa1[i]);
}
public void m1(double a) {
a += 100;
}
public void m5(double[] x) {
for(int i=0; i < x.length; i++)
x[i] += 100;
}
OUTPUT : 100.5
110.0 120.0 130.0 140.0