java - overridden method cant throw exception -
while compiling following code have got error
@override public void routecustomerrequest (int choice) throws unsupportedcustomerrequestexception{ //throw new unsupportedoperationexception("not supported yet."); switch(choice) { case '1': system.out.println("1. add new customer"); break; default : throw unsupportedcustomerrequestexception("hehehe"); } } // constructor class public class unsupportedcustomerrequestexception extends exception { public unsupportedcustomerrequestexception(string bong){ system.out.println(bong); }
}
its interface is
/* * change template, choose tools | templates * , open template in editor. */ package bankingappication; /** * * @author training */ public interface ibankingservices { public static string bankerresgistrationcode=null; public void enquirecustomer(); public int presentservicemenu(); public void routecustomerrequest(int choice); public boolean acceptdeposit(); public boolean acceptcheque(); public boolean processcheque(); //customer name can full or partial. public boolean providesummarystatement(string customername); public boolean addcustomer(); public boolean removecustomer(); public boolean updatecustomer(); } //please debug error
you can't declare overridden method throw broader exception.
in case exception broader no exception
Comments
Post a Comment