Java throwing error “ is not abstract and does not override abstract method in the

前端 未结 3 805
小鲜肉
小鲜肉 2020-12-12 03:10

I am unable to compile the below code written, Java always throws an error. Can you please help me out (P.S: I am new to Java, in a learning stage still). If anywhere, i hav

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-12 03:38

    Well as the error says - certain classes that implement the calci interface do not implement all the methods of that interface. When you are creating a class that implements an interface you need to implement all the methods from that interface, not only certain ones you are interested in. That's the whole point of interfaces. Otherwise you wouldn't be able to code against interfaces as for instance calci test = getCalciInstance().XXX() where XXX() is a method declared in calci might not be implemented depending on which implementation's instance getCalciInstance() would return!

    So all your classes need to implement the following methods:

    void add();
    void sub();
    void mul();
    void div();
    

提交回复
热议问题