Notas
throwing our own exception
Conteúdo das notas (1)
Página 1
Throwing our own exception
syntax:
throw new Throwble_Subclass
SAMPLE PROGRAM:
class MyException extends Exception
{
MyException(String msg)
{
super(msg);
}
}
class test
{
p.s.v.m()
{
int x=5,y=10;
}
try
{
float z=(float)x/(floaat)y;
if(z<0.01)
{
throw new MyException("number is too small");
}
}
catch(MyException e)
{
s.o.p("caught my exception");
s.o.p(e.getmessage());
}
finally
s.o.p("i'm always here");
}
}
}
Informações
- Descrição
- JAVA Notas sobre throwing our own exception, criado por shanid m em 13-10-2016.
- Criado por
- shanid m
- Visualizações
- 0
- Avaliação