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

前端 未结 18 872
日久生厌
日久生厌 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:02

    all classes extends the java.lang.Object by default. You can see it here

    0 讨论(0)
  • 2021-01-03 20:05

    It is silly code. Every class in Java extends an Object class. No need to type this explisitly

    0 讨论(0)
  • 2021-01-03 20:07

    Extends clause is optional as stated in Java Language Specification. If it is omitted, the class is derived from java.lang.Object. It is just a matter of coding style to write it or not to write it in this case. Usually it is omitted.

    0 讨论(0)
  • 2021-01-03 20:09

    It's unneeded. Every class in Java extends Object at some level. Leave it out, unless you need to clarify something specific.

    0 讨论(0)
  • 2021-01-03 20:11

    All objects in Java implicitly extend Object, so I'd say it's redundant.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题