Same method in Interface and Abstract class

前端 未结 4 1463
一个人的身影
一个人的身影 2020-11-30 03:02

I came to situation :

public interface Intr {
    public void m1();
}

public abstract class Abs {
    public void m1() {
        System.out.println(\"Abs.m1         


        
4条回答
  •  無奈伤痛
    2020-11-30 03:13

    You are satisfying both conditions at once; ie. the one implementation is at the same time fulfilling the abstract class requirements and the interface requirements.

    As a note, unless you are using Intr in another inheritance chain, you don't need it. Also, it might make sense to move the implements Intr up to the abstract class definition.

提交回复
热议问题