- ✕This summary was generated using AI based on multiple online sources. To view the original source information, use the "Learn more" links.
RuntimeException in Java is a subclass of Exception that represents exceptions that can occur during the normal operation of the Java Virtual Machine (JVM). These exceptions are unchecked, meaning they do not need to be declared in a method or constructor's throws clause.
Example
public class Example {public static void main(String[] args) {int[] numbers = {1, 2, 3};System.out.println(numbers[5]); // Throws ArrayIndexOutOfBoundsException}}Copied!✕CopyIn this example, accessing an invalid array index throws an ArrayIndexOutOfBoundsException, a subclass of RuntimeException.
Characteristics of RuntimeException
Unchecked Exceptions
RuntimeExceptions are unchecked exceptions. This means that the compiler does not require methods to catch or specify them. They are typically used for programming errors such as logic mistakes.
Common Subclasses
Some common subclasses of RuntimeException include:
NullPointerException
ArrayIndexOutOfBoundsException
IllegalArgumentException
ClassCastException
Constructors
RuntimeException (Java SE 17 & JDK 17) - Oracle
Oct 20, 2025 · RuntimeException is the superclass of those exceptions that can be thrown during the normal operation of the Java Virtual Machine. RuntimeException and its subclasses are unchecked …
RuntimeExceptionとは?初心者のJavaの勉強
Aug 29, 2020 · RuntimeExceptionの子クラスで発生した例外全てをキャッチすることができます。 どんな例外が発生するかわからない時にひとま …
Java – RuntimeExceptionエラーの原因と対処法
Apr 15, 2025 · この記事では、Javaにおける RuntimeException の概要や主な種類、原因、対処法、そしてそれを防ぐためのベストプラクティスについて詳しく …
Java RuntimeException Class - Complete Tutorial with Examples
Apr 13, 2025 · This tutorial covered RuntimeException with practical examples demonstrating common scenarios. Understanding these exceptions helps write more robust Java code that properly handles …
Java Program to Handle Runtime Exceptions - GeeksforGeeks
Jul 23, 2025 · RuntimeException is the superclass of all classes that exceptions are thrown during the normal operation of the Java VM (Virtual Machine). The RuntimeException and its subclasses are …
- People also ask
Java - RuntimeException - Online Tutorials Library
In this chapter, we have learned about the RuntimeException class in Java. We have discussed its hierarchy, causes, constructors, methods, subclasses, and how to handle it using try-catch blocks.
How to Throw Runtime Exception in Java - Delft Stack
Mar 11, 2025 · This tutorial demonstrates how to throw runtime exceptions in Java. Learn about the different types of runtime exceptions, how to create custom …
Lesson 17.2: How to handle runtime exception in Java
Feb 11, 2025 · A RuntimeException in Java is an error that happens while the program is running. Unlike checked exceptions, Java doesn’t force you to handle …
Java : RuntimeException (非チェック例外) - API使用例
May 22, 2021 · RuntimeException (Java SE 22 & JDK 22) の使い方まとめです。 ほとんどのメソッドにサンプルコードがあります。 API仕様書のおともにどうぞ。
Java RuntimeException - understanding and using ...
Apr 2, 2025 · RuntimeException is a special category of exceptions in Java that represents problems which may occur during normal program execution. Unlike checked exceptions, RuntimeExceptions …