9_方法参数的值传递

 1 package coms;
 2 /**
 3  * 方法参数的值传递
 4  * @author user
 5  *
 6  */
 7 public class javalx15 {
 8     /*
 9     //内置类型方法参数传递,新建一个变量给方法
10     public static void main(String[] args) {
11         int a=10;
12         test(a);
13         System.out.println(a);
14 
15     }
16     public static void test(int b){
17         b++;
18         System.out.println(b);
19     }*/
20     
21     
22     
23     //复杂类型方法参数传递,把对象的引用方法,没有新建对象
24     public static void main(String[] args){
25         Studentc a=new Studentc();
26         test(a);
27         System.out.println(a.age);
28         
29     }
30     public static void test(Studentc a){
31         a.age++;
32     }
33 
34 }
35 class Studentc{
36     int age=20;
37 }

 

posted on 2015-02-10 15:10  皮鞋很忙  阅读(74)  评论(0)    收藏  举报

导航