Does 'extends Object' have a purpose or is it redundant?

前端 未结 18 978
日久生厌
日久生厌 2021-01-03 19:25

Following a tutorial on the internet regarding Soap development with Java, I found this link, with a rather unusual code for myself.

The code:

public         


        
18条回答
  •  死守一世寂寞
    2021-01-03 20:11

    It is legal but useless boilerplate. Everything extends Object so the language spec allows you to leave it out, and it generally should be left out (some writers of coding standards disagree).

    The situation is the same in generics (extends Object is implicit and redundant), it is just that for some reason (I have seen some claim early buggy Generics implementations had issues with the ? wildcard) it has caught on a bit more there.

提交回复
热议问题