StackOverflowError 和 OutOfMemoryError

package cn.zno.outofmomery;

import java.util.ArrayList;
import java.util.List;

public class Test {

    void s() {
        s();
    }

    void h() {
        List<byte[]> list = new ArrayList<byte[]>();
        while (true) {
            list.add(new byte[1024 * 1024]);
        }
    }

    public static void main(String[] args) {
     // new Test().s(); // StackOverflowError
        new Test().h(); // OutOfMemoryError
    }
}
原文地址:https://www.cnblogs.com/zno2/p/4571551.html