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

前端 未结 18 870
日久生厌
日久生厌 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 19:46

    All classes extend Object implicitly anyway so it's just redundant coding having no impact.

    0 讨论(0)
  • Any class that doesn't explicitly extend another class,implicitly extends Object

    0 讨论(0)
  • 2021-01-03 19:49

    Looks a bit like generated code - it's extra effort for a source code generator to omit the "extends" clause if it is not needed, especially if the generator is template-based.

    0 讨论(0)
  • 2021-01-03 19:51

    My vote, plain dumb - but then I only play with Java...

    But any class inherits from the Object Class as far as I know...

    0 讨论(0)
  • 2021-01-03 19:53

    I think it's redundant.

    In Junit source code:

    public class TestFailure extends Object {}
    

    I don't know why this class extends Object.

    0 讨论(0)
  • 2021-01-03 19:53

    As java is an object oriented language, it supports inheritance which inherits the properties of the another class, for example all java objects inherits from java.lang.Object class.From the above example it is understood that it is the explanation of inheritance. Note that all classes, whether they state so or not, will be inherit from java.lang.Object.

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