Throwing multiple exceptions Java

Throws multiple exceptions Java example source code

	public void callFc() 
	throws IndexOutOfBoundsException, ArithmeticException
	{
         // my code for example:
         String[] sArray = {"aa","bb"};
         String str = sArray[5]; // IndexOutOfBoundsException
 
         int n = 5 / 0; // ArithmeticException
        }
 
public void someFC (){
try{
     callFc();
    }
 catch(IndexOutOfBoundsException e){
      Log.e("TAG", e.toString());
  }
 catch(ArithmeticException e2){ 
      Log.e2("TAG",e2.toString()); 
  }
}
This entry was posted in Android Examples Code, Bugs, warnings, errors and tagged , . Bookmark the permalink.


Comments are closed.



2,998 views