From 34456d988c627a58ce8fca141cfb488c6d7998d4 Mon Sep 17 00:00:00 2001 From: Jakukyo Friel Date: Mon, 22 Aug 2016 06:06:57 +0800 Subject: java: In Java 8, interfaces can have default method. (#2337) --- java.html.markdown | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'java.html.markdown') 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; } -- cgit v1.2.3