I was trying to extend from a class and implement an interface as well.Here is my code.
class A {
public void print1() {
System.out.println("Hello Class");
}
}
interface B {
public void print2();
}
class C extends A implements B {
public void print2() {
System.out.println("Interface");
}
}
First I did is
class C implements B extends A {
public void print2() {
System.out.println("Interface");
}
}
And it leads to an error.
It seems that extends
keyword needs to come before implements
. Why it is needed ? Any specific reasons or is it just the way java is developed. ?