Java 哪个班级是所有班级的超班级

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20906091/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 05:12:39  来源:igfitidea点击:

Which class is super class of all classes

javaandroid

提问by user3153149

I am a Java beginner. I am little bit confused as to which is the Super class of all classesin Java?

我是Java初学者。我有点困惑Java中所有类Super 类是哪个?

采纳答案by keyboardsurfer

From the Objectdocumentation:

Object文档:

The root class of the Java class hierarchy. All non-primitive types (including arrays) inherit either directly or indirectly from this class.

Java 类层次结构的根类。所有非原始类型(包括数组)直接或间接继承自此类。

回答by Si-N

I believe it's java.lang.Object

我相信它是 java.lang.Object

回答by Benoit

The Object class is the super class of all classes. Same as Java

Object 类是所有类的超类。与Java相同

回答by Infinite Recursion

Object class is the superclass.

对象类是超类。

Reference: Android documentation http://developer.android.com/reference/java/lang/Object.html

参考:Android 文档http://developer.android.com/reference/java/lang/Object.html

The root class of the Java class hierarchy. All non-primitive types (including arrays) inherit either directly or indirectly from this class.

Java 类层次结构的根类。所有非原始类型(包括数组)直接或间接继承自此类。

回答by Ramakishna Balla

java.lang.Object

对象

it is The root class of the Java class hierarchy. All non-primitive types (including arrays) inherit either directly or indirectly from this class. more info at : http://developer.android.com/reference/java/lang/Object.html

它是 Java 类层次结构的根类。所有非原始类型(包括数组)直接或间接继承自此类。更多信息:http: //developer.android.com/reference/java/lang/Object.html

回答by Saro Ta?ciyan

Objectis the super class of all other classes you use, including the ones you implemented.

Object是您使用的所有其他类的超类,包括您实现的类。

And you'll see the following methods are inherited from Objectin every class.

您会看到以下方法是从Object每个类中继承而来的。

  • equals(Object o)
  • getClass()
  • hashCode()
  • notify()
  • notifyAll()
  • toString()
  • wait()
  • wait(long millis, int nanos)
  • wait(long millis)
  • 等于(对象 o)
  • 获取类()
  • 哈希码()
  • 通知()
  • 通知所有()
  • toString()
  • 等待()
  • 等待(长毫秒,整数纳米)
  • 等待(长毫秒)

You may find thisuseful

你可能会发现很有用

回答by Atul Singh Rajpoot

java.lang.Object class is the super class for all java classes. you can see with following example:

java.lang.Object 类是所有 java 类的超类。你可以看到下面的例子:

   class test
   {
    public static void main(String a[]){
     System.out.println("hi this java");
    }
   }

save program with- test.java compile program using - javac test.java

使用-test.java 保存程序 使用-javac test.java 编译程序

now type following cmd to see real output ; javap test

现在键入以下 cmd 以查看实际输出;测试

  • output--

    class test extends java.lang.Object{
     test();
     public static void main(java.lang.String[]);
    }
    
  • 输出——

    class test extends java.lang.Object{
     test();
     public static void main(java.lang.String[]);
    }
    

the first line itself tells that by default it extends java.lang.Object.

第一行本身说明默认情况下它扩展 java.lang.Object。

回答by lolu

as people already said, Object is the class everyone inherit from. and fyi, u can also overrid methods like "toString()", "equals()" to suit your personal new Class needs.

正如人们已经说过的, Object 是每个人都继承的类。仅供参考,您还可以覆盖诸如“toString()”、“equals()”之类的方法以满足您个人的新类需求。

thisis a nice tutorial for starting.

是一个很好的入门教程。

回答by AmitG

java.lang.Objectis a super class of any class by default.
Also Objectclass is a superclass for all interfacesby default, Ex

java.lang.Object默认是任何类的超类。
此外,默认情况下Object类是所有接口的超类,例如

public interface ICommand
{

}

class Test {
   ICommand c;
   Object o = c;  //works fine
}

回答by Vinay Guru

Object Class is the Base class or Super Class of all Classes. Its a Class not an Instance of an Object. Its the Biggest Class in java

对象类是所有类的基类或超类。它是一个类而不是一个对象的实例。它是java中最大的类