![]() |
![]() |
|
![]() |
![]() |
|
Programmierung Rat & Tat für Programmierer |
|
Themen-Optionen | Ansicht |
![]() |
#2 |
Inventar
![]() Registriert seit: 13.06.2001
Beiträge: 1.830
|
![]() IMO kann man keine Methode die keine Exception wirft mit einer die eine wirft überschreiben. Du wirst also schon in der vererbenden Methode ein "throws XYZException" dazutun müssen.
Du hast public class Konto{ ... public static void einzahlen(){ ... } } und public class Girokonto extends Konto ... public statuc void einzahlen throws EinzahlEception(){ ... } } Wenn du jetzt: Konto k=new Girokonto(); k.einzahlen(); ausführst und in einzahlen() eine Exception geworfen wird, wird sie nirgens gefangen. Daher muß die Exception schon bei Konto eingefüft werden: public class Konto{ ... public static void einzahlen() throws EinzahlException{ ... } } Jak
____________________________________
Join the DNRC | Godwin\'s Law (thx@stona) Documentation is like sex: If it\'s good, it\'s very, very good. If it\'s bad, it\'s better than nothing. \"In theory, theory and practice are the same. In practice, they are not\" (Lawrence Berra) |
![]() |
![]() |
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1) | |
|
|