CH-4 Exception Handling in Java
CH-4 Exception Handling in Java
int a=50/0;//ArithmeticException
NullPointerException
If we have null value in any variable,
performing any operation by the variable
occurs an NullPointerException.
String s=null;
System.out.println(s.length());//NullPointerEx
ception
NumberFormatException
The wrong formatting of any value, may occur
NumberFormatException. Suppose I have a
string variable that have characters,
converting this variable into digit will occur
NumberFormatException.
String s="abc";
int i=Integer.parseInt(s);//NumberFormatException
ArrayIndexOutOfBoundsException
If you are inserting any value in the wrong
index, it would result
ArrayIndexOutOfBoundsException as shown
below:
hi friends
normal flow...