Manejo de errores dudas

Iniciado por Cazs03, 8 Marzo 2013, 17:37 PM

0 Miembros y 1 Visitante están viendo este tema.

Cazs03

Bueno tengo este pequeño codigo
class DemoException{
public class ThomasException {
public ThomasException() throws Exception{
throw new Exception();
}
}
class DemoException{
public static void main(String[]args){
int size;
for(size=3;size>-3;size--){
try{
System.out.println("size ="+size);
if(size==0){
throw new ThomasException();
}
int myArray[]=new int[size];
System.out.println(myArray.length);
}
catch(NegativeArraySizeException e){
System.out.println("Negative array" +e.toString());
}
catch(ThomasException e)
{
System.out.println("thomasexception is"+e.toString());
}
}
}
}

Y mi duda esta en que
throw new ThomasException();
pone que es un error como hago para que funcione no explicarme mejor la cuestion esque funcione ese thomasexception como throw como tengo que declararlo para que la clase lo tome ?



1mpuls0

abc