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

后端 未结 4 501
独厮守ぢ
独厮守ぢ 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条回答
  •  萌比男神i
    2021-01-07 10:47

    This flexibility is not exists, because "int" is primitive datatype and "Integer" is class/wrapper of int datatype. And "int" is not a subclass of "Integer", while "Integer" is subclass of "Object" class

提交回复
热议问题