OutOfMemoryError大数组,例如图片加载。
public class MockOutOfMemoryError
{
public static void main(String[] args)
{
List<int[]> list = new ArrayList<int[]>();
for (;;)
{
int[] temp = new int[1000000];
list.add(temp);
}
}
}
StackOverFlowError,递归层数太深
public class MockStackOverFlow
{
public static void method()
{
for(;;)
{
method();
}
}
public static void main(String[] args)
{
method();
}
}