Java interface keyword example
- Details
- Written by Nam Ha Minh
- Last Updated on 19 August 2019   |   Print Email
In Java, the interface keyword is used to declare an interface:
interface Vehicle { void start(); void stop(); }
Interface is a programming construct that defines a contract which must be adhered by implementing classes. The methods defined in an interface must have no body and end with a semicolon. The implementing classes will provide concrete implementation for the methods.
Related keywords: class and implements. See all Java keywords.
Related Topics:
Other Recommended Tutorials:
- 9 Rules about Constructors in Java
- 12 Rules and Examples About Inheritance in Java
- 12 Rules of Overriding in Java You Should Know
- 10 Java Core Best Practices Every Java Programmer Should Know
- Understand how variables are passed in Java
- Understand encapsulation in Java
Comments