这里是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[];
数组将继承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
这里发生了什么?
编辑:
根据答案,我现在知道它是java.lang.reflect
包中的一个final
类。
我现在在我的Android项目中创建了一个名为Array.java的类,并将其添加到java.lang.reflect
包中。为了确认这是原始类的方法,Eclipse给出了错误“...已经存在于path/to/android.jar”
如果我将同样的类写成java.lang.reflect.Array
,但更改toString()
方法... 这应该在我的应用程序中起作用,对吗?
java.lang.reflect
包中的“final”类。 - user207421