- public class Demo {
- public static void main(String[] args) {
- int a = 1;
- add(a);
- Koo koo = new Koo();add(koo);
- System.out.println(a+","+koo.a);//输出1,2 为什么koo.a为2呢?总觉得应该跟a的值一样是1
- System.out.println(koo);
- }
- public static int add(int a){
- a++;return a;
- }
- public static int add(Koo koo){
- Koo k = koo;
- k.a++;return k.a;
- }
- }
- class Koo{
- int a = 1;
- }
复制代码 |
|