Interface list in the inherited interface collection, interface collection there is a size () method, in the interface list and the size () method, what is the point? (cover a lot of ways, see)
Public interface List<e> extends collection<e>
1. Both the parent interface and the sub-interface are abstract (not implemented), and the subclass does not change the method of the parent class, which does not make sense at the functional level.
2. The subclass method cannot narrow the access rights of the overridden methods, but the methods inside the interface can only be public, so the child interface method overrides the parent interface method and cannot change the scope of the method.
The subclass method cannot throw more exceptions than the overridden method, so the sub-interface method overrides the parent interface method cannot change the method that can change the exception thrown by the method.
3. Sub-interface methods overriding the parent interface method is more about the readability of the class, reminding the consumer that this method is available here.
InterfaceA {voidMethod ()throwsException;}InterfaceBextendsA {voidMethod ();//there is no exception thrown here} Public classCImplementsB { Public Static voidMain (string[] args) {A a=NewC (); b b=NewC (); //catching exceptions for Class A method methods Try{A.method (); } Catch(Exception e) {//TODO auto-generated Catch blockE.printstacktrace (); } b.method (); } @Override Public voidmethod () {System.out.println ("Method"); }}
Thinking of the method of overriding the parent interface in Java sub-interface method