堆溢出:
/**
* @author LXA
* 堆溢出
*/
public class Heap
{
public static void main(String[] args)
{
ArrayList list=new ArrayList();
while(true)
{
list.add(new Heap());
}
}
}
报错:
java.lang.OutOfMemoryError: Java heap space
栈溢出:
/**
* @author LXA
* 栈溢出
*/
public class Stack
{
public static void main(String[] args)
{
new Stack().test();
}
public void test()
{
test();
}
}
报错:
java.lang.StackOverflowError