Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Java Programming Code Examples

Java > Learning Code Examples

Raise Exceptions

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
Raise Exceptions package com.ack.learning; /** * This example demonstrates how to catch * multiple exceptions that are raised in * a try block */ public class RaiseExceptions { public static void main( String[] args ) { try { Integer.parseInt( "a" ); double[] amounts = new double[-10]; "hello".charAt( -1 ); String str = args[6]; ( (String) null ).length(); int a = 3 / 0; } catch( NumberFormatException nfex ) { System.out.println( nfex ); } catch( NegativeArraySizeException nasex ) { System.out.println( nasex ); } catch( StringIndexOutOfBoundsException siex ) { System.out.println( siex ); } catch( ArrayIndexOutOfBoundsException arex ) { System.out.println( arex ); } catch( NullPointerException npex ) { System.out.println( npex ); } catch( ArithmeticException aex ) { System.out.println( aex ); } } }