G.12.2. Interface Payable
The declaration of interface Payable
begins in Fig. G.23 at line 4. Interface Payable
contains public abstract
method getPaymentAmount
(line 6). The method is not explicitly declared public
or abstract
. Interface methods are always public
and abstract
, so they do not need to be declared as such. Interface Payable
has only one method—interfaces can have any number of methods. In addition, method getPaymentAmount
has no parameters, but interface methods can have parameters. Interfaces may also contain fields that are implicitly final
and static
.
1 // Fig. G.23: Payable.java 2 // Payable interface declaration. 3 4 public interface Payable ...
Get Android™ How to Program, Second 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.