diff options
| author | Jakukyo Friel <weakish@gmail.com> | 2016-08-22 06:06:57 +0800 | 
|---|---|---|
| committer | ven <vendethiel@hotmail.fr> | 2016-08-22 00:06:57 +0200 | 
| commit | 34456d988c627a58ce8fca141cfb488c6d7998d4 (patch) | |
| tree | 8976f0accdc9a4cee7978fe5b1e92a4f7d5bc970 /java.html.markdown | |
| parent | d81e9735c237a28b22632d0d168cc69d7dc4b19b (diff) | |
java: In Java 8, interfaces can have default method. (#2337)
Diffstat (limited to 'java.html.markdown')
| -rw-r--r-- | java.html.markdown | 8 | 
1 files changed, 6 insertions, 2 deletions
diff --git a/java.html.markdown b/java.html.markdown index 1f7d4115..56bffd88 100644 --- a/java.html.markdown +++ b/java.html.markdown @@ -585,10 +585,14 @@ public interface Edible {  public interface Digestible {      public void digest(); +    // In Java 8, interfaces can have default method. +    // public void digest() { +    //     System.out.println("digesting ..."); +    // }  }  // 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() {          // ... @@ -636,7 +640,7 @@ public abstract class Animal      // Method can have a body      public void eat()      { -        System.out.println("I am an animal and I am Eating.");   +        System.out.println("I am an animal and I am Eating.");          // Note: We can access private variable here.          age = 30;      }  | 
