'extends Object'有目的还是多余? [英] Does 'extends Object' have a purpose or is it redundant?

查看:82
本文介绍了'extends Object'有目的还是多余?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在互联网上关于使用Java进行Soap开发的教程之后,我找到了此链接,给我一个相当不寻常的代码。

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

代码:

public class SoapService extends Object {

    /** Creates new SoapService */
    public SoapService() {
    }

/** This is the SOAP exposes method
*/
    public String sayGreeting(String name)
    {
        return "Hello "+name;
    }
}

'extends Object'语法是什么?我从未遇到过这种语法(仅限Generics)。

What's with the 'extends Object' syntax ? I've never encountered this kind of syntax (only on Generics).

这种语法是否有任何目的或是普通愚蠢?

Does this syntax has any purpose or is 'plain dumb' ?

推荐答案

除非Object类实际上不是 java.lang.Object 类(该教程不包含导入,因此很难看到), extends Object 是多余的。

Unless the Object class is not actually the java.lang.Object class (the tutorial does not include the imports, so it's hard to see), the extends Object is redundant.

这篇关于'extends Object'有目的还是多余?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆