所以对于这个程序,我不明白为什么时间仍然是0。为什么计数能增加但时间不是?我以为更改参数名称会改变这个但我错了。这与变量的范围或完全不同的东西有关吗? 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 }
}