Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
How to handle Assertion Error in Java?
In order to handle the assertion error, we need to declare the assertion statement in the try block and catch the assertion error in the catch block.
Let us see a program on how to handle Assertion Error in Java −
Example
public class Example {
public static void main(String[] args) throws Exception {
try {
assert args.length > 0;
}
catch (AssertionError e) {
System.out.println(e.getMessage());
}
}
}
Output

Advertisements
