Skip to content

Instantly share code, notes, and snippets.

View anjanashankar9's full-sized avatar

Anjana Shankar anjanashankar9

View GitHub Profile
@anjanashankar9
anjanashankar9 / MyInterfaceImpl.java
Created October 25, 2015 14:10
Interfaces in Java8
public class MyInterfaceImpl implements MyInterface {
@Override public void method1() {
System.out.println("Implementation of method 1");
}
@Override public void method2() {
System.out.println("Implementation of method 2");
}
public static void main(String[] args){
@anjanashankar9
anjanashankar9 / ConsoleOutput.txt
Created October 25, 2015 14:12
Interfaces in Java8
Implementation of method 1
Implementation of method 2
@anjanashankar9
anjanashankar9 / ConsoleOutput.txt
Created October 25, 2015 14:12
Interfaces in Java8
Implementation of method 1
Implementation of method 2
@anjanashankar9
anjanashankar9 / MyInterface.java
Last active October 25, 2015 14:31
Interfaces in Java8
public interface MyInterface {
/**
* All the methods of an interface are public by default
*/
void method1();
void method2();
default void newMethod(){
System.out.println("This is the default implementation of the method");
}
}
@anjanashankar9
anjanashankar9 / MyInterfaceImpl.java
Created October 25, 2015 14:33
Interfaces in Java8
public class MyInterfaceImpl implements MyInterface {
@Override public void method1() {
System.out.println("Implementation of method 1");
}
@Override public void method2() {
System.out.println("Implementation of method 2");
}
public static void main(String[] args){
@anjanashankar9
anjanashankar9 / Output.txt
Created October 25, 2015 14:35
Interfaces in Java8
Implementation of method 1
Implementation of method 2
This is the default implementation of the method
@anjanashankar9
anjanashankar9 / InterfaceA.java
Last active October 25, 2015 15:01
Interfaces in Java8
public interface InterfaceA {
default void method(){
System.out.println("Interface A default method");
}
}
@anjanashankar9
anjanashankar9 / InterfaceB.java
Created October 25, 2015 15:02
Interface in Java8
public interface InterfaceB {
default void method(){
System.out.println("Interface A default method");
}
}
@anjanashankar9
anjanashankar9 / InterfaceImpl.java
Created October 25, 2015 15:04
Interfaces in Java8
public class InterfaceImpl implements InterfaceA,InterfaceB{
}
@anjanashankar9
anjanashankar9 / InterfaceImpl.java
Created October 26, 2015 05:55
Interfaces in Java8
public class InterfaceImpl implements InterfaceA,InterfaceB{
@Override public void method() {
System.out.println("Default method in implementation class");
}
public static void main(String[] args){
InterfaceA obj = new InterfaceImpl();
obj.method();
}
}