rale77
Aktivan član
- Poruka
- 1.306
Jel moze neko ukratko da objasni kako se hvataju izuzeci u javi...
Da napise primer jednog try{.....throw....}
catch{....}
bloka.
Posto vise stvarno ne znam sta god uradim izbacuje:
unreported exception MyException; mast be cougth or declared to be thrown
Ovo je deo koda...
class{
.....
public static void main(String[] args) {
try{
.
.
.
if(a==b) throw new MyException("Desila se greska!!!");
}
catch (MyException ex) {
System.out.println("Greska!!!");
}
}
}
class MyException extends Exception {
MyException(String s)
{
super(s);
System.out.println(s);
}
}
Da napise primer jednog try{.....throw....}
catch{....}
bloka.
Posto vise stvarno ne znam sta god uradim izbacuje:
unreported exception MyException; mast be cougth or declared to be thrown
Ovo je deo koda...
class{
.....
public static void main(String[] args) {
try{
.
.
.
if(a==b) throw new MyException("Desila se greska!!!");
}
catch (MyException ex) {
System.out.println("Greska!!!");
}
}
}
class MyException extends Exception {
MyException(String s)
{
super(s);
System.out.println(s);
}
}