我在运行一下代码时- //定义一个接口
- interface Inter
- {
- //接口中的两个方法
- public void method1();
- public void method2();
- //public void method3();
- }
- //Test1实现了接口Inter
- class Test1 implements Inter
- {
- public void method1()
- {
- System.out.println("method1 is running");
- }
- }
- class InterDemo
- {
- public static void main(String[] args)
- {
- //实例化Test1对象
- Test1 test=new Test1();
- //调用method1方法
- test.method1();
- }
- }
复制代码 出现了错误,
错误信息是:Test1不是抽象的,并且未覆盖Inter中的抽象方法method2,请问在实现接口时为什么要全部覆盖接口中的方法啊?? |