Notizen
throwing our own exception
Inhalt der Notizen (1)
Seite 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");
}
}
}
Informationen
- Beschreibung
- JAVA Notiz am throwing our own exception, erstellt von shanid m am 13/10/2016.
- Erstellt von
- shanid m · Okt 2016
- Aktualisiert
- 14 Okt 2016
- Aufrufe
- 0
- Bewertung