8_对象变量赋值

 1 package coms;
 2 
 3 /**
 4  * 对象变量赋值,没有创建新对象,而是把原来的对象引用给了新的对象变量,即两个对象引用指向一个实际对象
 5  * @author user
 6  *
 7  */
 8 public class javalx14 {
 9 
10     public static void main(String[] args) {
11         int a=10;
12         int b=a;
13         b++;
14         System.out.println(b);
15         
16         
17         Studentb aa=new Studentb();
18         Studentb bb=new Studentb();
19         Studentb cc=bb;
20         
21         
22         cc.age=23;
23         System.out.println(aa.age);
24         System.out.println(bb.age);
25         
26     }
27 }
28 class Studentb{
29     int age=20;
30 }

 

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

导航