i start learn java, and i build 'swap' function that replaces numbers.
when i run this code, its not replace them.
how could i solve this problem?
public static void swap(double i, double j){
double temp = i;
i = j;
j = temp;
}
this in the main:
double i = 1;
double j = 2;
System.out.println(i+" - "+ j);
swap(i, j);
System.out.println(i+" - "+ j);
in the Console i see:
1.0 - 2.0
1.0 - 2.0
and i need to see:
1.0 - 2.0
2.0 - 1.0