复制代码
- //:Assignment.java
- //Assignmentwithobjectsisabittricky
- packagec03;
- classNumber{
- inti;
- }
- publicclassAssignment{
- publicstaticvoidmain(String[]args){
- Numbern1=newNumber();
- Numbern2=newNumber();
- n1.i=9;
- n2.i=47;
- System.out.println("1:n1.i:"+n1.i+
- ",n2.i:"+n2.i);
- n1=n2;
- System.out.println("2:n1.i:"+n1.i+
- ",n2.i:"+n2.i);
- n1.i=27;
- System.out.println("3:n1.i:"+n1.i+
- ",n2.i:"+n2.i);
- }
- }///:~
复制代码
- //:PassObject.java
- //Passingobjectstomethodscanbeabittricky
- classLetter{
- charc;
- }
- publicclassPassObject{
- staticvoidf(Lettery){
- y.c=z;
- }
- publicstaticvoidmain(String[]args){
- Letterx=newLetter();
- x.c=a;
- System.out.println("1:x.c:"+x.c);
- f(x);
- System.out.println("2:x.c:"+x.c);
- }
- }///:~
欢迎光临 仓酷云 (http://ckuyun.com/) | Powered by Discuz! X3.2 |