相关疑难解决方法(0)

为什么没有java.lang.Array类?如果java数组是一个Object,它不应该扩展Object吗?

这是java包树:http: //docs.oracle.com/javase/7/docs/api/java/lang/package-tree.html

我读了一篇关于Java的教程,该教程表明在Java数组中是对象.

数组类在哪里?为什么我们可以制作这样的数组:

byte[] byteArr = new byte[];
char[] charArr = new char[];
int[] intArr = new int[];
Run Code Online (Sandbox Code Playgroud)

并且数组将从Object继承方法; 例如:

    byte thisByte = 1;
    byte thatByte = 2;
    byte[] theseBytes = new byte[] {thisByte, thatByte};
    int inheritance = theseBytes.length; //inherited 'length' field and some methods
    int wasntInWill = thatByte.length; //error
Run Code Online (Sandbox Code Playgroud)

这里发生了什么?

编辑:

根据答案,我现在知道它是一个包装finaljava.lang.reflect.

我现在已经java.lang.reflect在我的Android项目中创建了一个包,并为其添加了一个名为Array.java的类.为了确认这是原始类的方式,Eclipse给了我错误"...已存在于path/to/android.jar"

如果我写出同一个类,java.lang.reflect.Array但改变toString()方法......这应该在我的应用程序中正常工作吗?

java arrays object

37
推荐指数
3
解决办法
2万
查看次数

标签 统计

arrays ×1

java ×1

object ×1