Describe the difference between passing a parameter of a primitive type and passing a parameter of a reference type. Show the output of the following programs:
public class Test {
public static void main(String[] args) {
Count myCount = new Count();
int times = 0;
for (int i = 0; i<100; i++)
increment(myCount, times);
System.out.println("count is " + myCount.count);
System.out.println("times is " + times);
}
public static void increment(Count c, int times) {
c.count++;
times++;
}
}
public class Count {
public int count;
public Count(int c) {
count = c;
}
public Count() {
count = 1;
}
}
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.