In Java, is it possible to override methods if return types are respectively a primitive and its wrapper class?

后端 未结 4 500
独厮守ぢ
独厮守ぢ 2021-01-07 10:27

While working with the idea of overriding and overridden methods in Java I have noticed that there is some flexiblity given for the return types of such methods.

Her

4条回答
  •  难免孤独
    2021-01-07 10:31

    For first example:

    Method in A:
    public Object some_method() {....}
    Method in B:
    public Integer some_method() {....}
    

    this type of overriding possible, but rest for two example overriding not possible.

提交回复
热议问题