java学习笔记1:对象的"引用"
终于可以在上课,配linux的空隙里开始学习java的编程基础,今天是第一节,呵呵,看代码:
结果是什么呢,想想再看下面,看看你想的对不对,??? (w)
class Number{
int i;
}
public class Lession5{
public static void main(String[] args)
{
Number n1= new Number();
Number n2= new Number();
n1.i=9;
n2.i=47;
System.out.println("1: n1.1="+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);
}
}
int i;
}
public class Lession5{
public static void main(String[] args)
{
Number n1= new Number();
Number n2= new Number();
n1.i=9;
n2.i=47;
System.out.println("1: n1.1="+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);
}
}
结果是什么呢,想想再看下面,看看你想的对不对,??? (w)
答案