Hope this example would help
public class Exemple {
public static void main ( String[] args ) {
int x;
double number;
String s ;
// Bloc 1
System.out.println ( "Start bloc 1" );
System.out.print ( " Pls enter a number from 1 - 10: " );
// Clavier.lireInt() is a local class not found in java lib, u
can replace by ur own
x = Clavier.lireInt();
System.out.println ( "End bloc 1" );
try {
// Bloc 2
System.out.println ( "Start bloc 2" );
System.out.print ( " Entrez UPC SVP: " );
s = Clavier.lireString(); // local class pls replace by ur
own or use BufferReader
number = Double.parseDouble(s);
System.out.println ( "End bloc 2" );
} catch ( NumberFormatException e ) {
// Bloc 3
// ArithmeticException NumberFormatException
System.out.println ( "Start bloc 3" );
System.out.println ( " string, " + e.getMessage() );
System.out.println ( "End bloc 3" );
} finally {
// Bloc 4
System.out.println ( "Start bloc 4" );
System.out.println ( " anything goes" );
System.out.println ( "End bloc 4" );
}
// Bloc 5
System.out.println ( "Start bloc 5" );
System.out.println ( " Normal Program end" );
System.out.println ( "End bloc 5" );
} // main
} // Exemple
ExceptionS:
IOException
FileNotFoundException (ex : could be from ileReader)
RuntimeException
ArithmeticException (ex : division by 0)
IllegalArgumentException
NumberFormatException
(ex : could be
generated from integer.parseInt(...))
IndexOutOfBoundsException
ArrayIndexOutOfBoundsException
StringIndexOutOfBoundsException
NegativeArraySizeException
NullPointerException
tks :)
--
ZeroCoded
------------------------------------------------------------------------
ZeroCoded's Profile:
http://www.highdots.com/forums/m1266
View this thread:
http://www.highdots.com/forums/t574789