- Apache Spark 2.x for Java Developers
- Sourav Gulati Sumit Kumar
- 121字
- 2021-07-02 19:01:55
Interfaces
Interfaces are the reference types in Java. They are used in Java to define contracts among classes. Any class that implements that interface has to adhere to the contract that the interface defines.
For example, we have an interface car as follows that consists of three abstract methods:
public interface Car { void shape(); void price(); void color(); }
Any class that implements this interface has to implement all the abstract methods of this interface unless it is an abstract class. Interfaces can only be implemented or extended by other interfaces, they cannot be instantiated.
Prior to Java 8, interfaces consisted only of abstract methods and final variables. In Java 8, interfaces may contain default and static methods as well.
推薦閱讀
- JavaScript百煉成仙
- Windows系統管理與服務配置
- Rust編程從入門到實戰
- 區塊鏈架構與實現:Cosmos詳解
- 技術領導力:程序員如何才能帶團隊
- Learn Swift by Building Applications
- Java設計模式及實踐
- Mastering Rust
- Unreal Engine 4 Shaders and Effects Cookbook
- Mastering Linux Network Administration
- Oracle GoldenGate 12c Implementer's Guide
- GitHub入門與實踐
- Scala編程實戰
- Machine Learning for OpenCV
- C# 7.1 and .NET Core 2.0:Modern Cross-Platform Development(Third Edition)