mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
java: Add @Override
for interfaces.
This commit is contained in:
parent
38be1f2f17
commit
0512b3120a
@ -4,6 +4,7 @@ language: java
|
|||||||
contributors:
|
contributors:
|
||||||
- ["Jake Prather", "http://github.com/JakeHP"]
|
- ["Jake Prather", "http://github.com/JakeHP"]
|
||||||
- ["Madison Dickson", "http://github.com/mix3d"]
|
- ["Madison Dickson", "http://github.com/mix3d"]
|
||||||
|
- ["Jakukyo Friel", "http://weakish.github.io"]
|
||||||
filename: LearnJava.java
|
filename: LearnJava.java
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -433,10 +434,12 @@ public interface Digestible {
|
|||||||
|
|
||||||
//We can now create a class that implements both of these interfaces
|
//We can now create a class that implements both of these interfaces
|
||||||
public class Fruit implements Edible, Digestible {
|
public class Fruit implements Edible, Digestible {
|
||||||
|
@Override
|
||||||
public void eat() {
|
public void eat() {
|
||||||
//...
|
//...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void digest() {
|
public void digest() {
|
||||||
//...
|
//...
|
||||||
}
|
}
|
||||||
@ -445,10 +448,12 @@ public class Fruit implements Edible, Digestible {
|
|||||||
//In java, you can extend only one class, but you can implement many interfaces.
|
//In java, you can extend only one class, but you can implement many interfaces.
|
||||||
//For example:
|
//For example:
|
||||||
public class ExampleClass extends ExampleClassParent implements InterfaceOne, InterfaceTwo {
|
public class ExampleClass extends ExampleClassParent implements InterfaceOne, InterfaceTwo {
|
||||||
|
@Override
|
||||||
public void InterfaceOneMethod() {
|
public void InterfaceOneMethod() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void InterfaceTwoMethod() {
|
public void InterfaceTwoMethod() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user