标签:对象 stat main log ati system public code java
1.
public class A { public int i = 10; public static void test(A a) { a.i += 10; } public static void main(String[] args) { A a = new A(); test(a); System.out.println(a.i); A b = a; test(b); System.out.println(a.i); System.out.println(b.i); A c = a; c.i = 0; System.out.println(c.i); System.out.println(b.i); System.out.println(a.i); } }
考点有两个:第一,创建对象时内存的开辟。第二,参数的传递。本例中其实就只有一个对象,就是第一行的new A(),这将在堆内存中开辟一块空间,
标签:对象 stat main log ati system public code java
原文地址:http://www.cnblogs.com/koushr/p/5873419.html