1、main方法调用其他方法
2、新建对象
StackOverflowError
public class test {
public static void main(String[] args) {
method();
}
public static void method() {
double d=0.1;
method();
}
}
OutOfMemoryError
import java.util.ArrayList;
import java.util.List;
public class test {
public static void main(String[] args) {
List<MyClass> list=new ArrayList<MyClass>();
while(true)
list.add(new MyClass());
}
}
class MyClass{
double[]ds=new double[64 * 1024];
}