16 lip 2010

Try, catch throwing Exception


@Test
public void testThrowing(){
try{ }catch(NumberFormatException ex){ }finally{ }
}

@Test
public void testThrowing2() throws Exception{
try{
throw new Exception(); //=> musi byc throws
}catch(NumberFormatException ex){
throw new Exception();
//int x =9; // unreachable exception!!!!!!!!
}finally{
/**
* Wypisze naewt jak jest w Main;
*/
System.out.println("finally"); //wypisze
}
}