Zol*_*i13 0 java exception-handling exception
对于涉及异常处理的家庭作业练习,我需要生成一个OutOfMemoryError异常,这样我就可以编写一个try-catch并捕获它:
"13.10(OutOfMemoryError)编写一个程序,使JVM抛出OutOfMemoryError并捕获并处理此错误."
我搜索了Java API,但在异常列表中的OutOfMemoryError异常中找不到任何内容.什么是OutOfMemoryError异常,如何为我的作业生成一个异常?
比创建数百万个对象更简单(并且保证工作):
public static void throwOomE() {
throw new well, you can just search for the rest of the answer
}
Run Code Online (Sandbox Code Playgroud)