java参数传递内存图解


 1 public class Param_test {
 2 
 3     public void change(Point point) {
 4 
 5         point.x = 3;
 6         point.y = 4;
 7 
 8     }
 9 
10     public static void main(String[] args) {
11         Param_test pt = new Param_test();
12         Point point = new Point();
13         pt.change(point);
14         System.out.println(point.x);
15         System.out.println(point.y);
16     }
17 
18 }
19 
20 class Point {
21 
22     int x;
23     int y;
24 }

 

 

 

 

 1 public class Param_test {
 2     public void change(Point point) {
 3         point = new Point();
 4         point.x = 3;
 5         point.y = 4;
 6 
 7     }
 8 
 9     public static void main(String[] args) {
10         Param_test pt = new Param_test();
11         Point point = new Point();
12         pt.change(point);
13         System.out.println(point.x);
14         System.out.println(point.y);
15     }
16 
17 }
18 
19 class Point {
20 
21     int x;
22     int y;
23 }


 

posted @ 2013-11-02 11:15  烫烫烫烫  阅读(343)  评论(0编辑  收藏  举报