代码案例一: package android.java.oop02; class Student { public int age; public String name; public void show() { System.out.println("age:" + age + " name:" + name); } } public class OopDemo01 { public static void main(String[] args) { Stude…
首先,我们来看一段程序内存溢出的代码: import java.util.ArrayList; import java.util.List; public class TestMemoryLeak { public static void main(String[] args) throws InterruptedException { List<int[]> list = new ArrayList<int[]>(); Runtime run = Runtime.getRunti…
今天,复习的是继承的内存分配.我们知道,Java中内存可以初略分为堆.栈.方法区. package sort; class Person{ public int age; public String name; public Person(){ System.out.println("父类"); say(); } public void say(){ System.out.println("有人说话."); } } class Student extends Per…