How to Implement Multiple Interfaces in Java


In this example we will show the method to implement multiple interfaces in Java.

Source Code

package com.beginner.examples;

interface Interface1 {
  public void method1();
}

interface Interface2 {
  public void method2();
}

// implement Interface1 and Interface2
class Example implements Interface1, Interface2 {
  public void method1() {
    System.out.println("method1");
  }
  public void method2() {
    System.out.println("method2");
  }
}

class MultipleInterface {
  public static void main(String[] args) {
    Example e = new Example();
    e.method1();
    e.method2();
  }
}

Output:

method1
method2
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments