So for this program I don't understand why times is still 0 . Why is count able to increment but times is not? I thought changing the parameter name would change this but I was wrong. Does this have to do with the scope of variables or something entirely different? Thanks1
1 public class Test {
2 public static void main(String[] args) {
3 Count myCount = new Count();
4 int times = 0;
5 for (int i = 0; i < 100; i++)
6 increment(myCount, times);
7 System.out.println("count is " + myCount.count);
8 System.out.println("times is " + times);
9 }
10
11 public static void increment(Count c, int times) {
12 c.count++;
13 times++;
14 }
15 }
1 public class Count {
2 public int count;
3 public Count(int c) {
4 count = c;
5 }
6 public Count() {
7 count = 1;
8 }
}