10.9.2 Interface Payable

The declaration of interface Payable begins in Fig. 10.11 at line 4. Interface Payable contains public abstract method getPaymentAmount. Interface methods are always public and abstract, so they do not need to be declared as such. Interface Payable has only one method, but interfaces can have any number of methods. In addition, method getPaymentAmount has no parameters, but interface methods can have parameters. Interfaces may also contain final static constants.

 1   // Fig. 10.11: Payable.java 2   // Payable interface declaration. 3  4   public interface Payable                                              5   {                                                                     6    ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.