programming-examples/java/Basics/Catching an exception.java

16 lines
305 B
Java
Raw Normal View History

2019-11-18 14:44:36 +01:00
Catching an exception
public class CatchingAnException {
public static void main( String[] args ) {
try {
// this throws a runtime exception, that is a divide by zero
int a = 3 / 0;
}
catch( ArithmeticException aex ) {
aex.printStackTrace();
}
}
}