你可以把基本上所有的实例化出来的东东看成是对象,也包括数组
可以是String[] a
同样也可以做个jLabel[] b
可以是String[] a
同样也可以做个jLabel[] b
解决方案 »
- Android下一段代码,请高手指点
- java基础学完了怎么办?
- 如何查看内存泄漏的原因?
- [200分]急速求助啊,JAVA语言编程谁可以用"雅可比迭代法"和"高斯-赛德尔迭代法"求解方程组啊
- Java问题
- java好书好多!
- $$$$$JAVA为什么容易混饭吃¥¥¥
- 谁有jbuilder2006的教程?我在jbuilder2006里建一个web module,然后在web module里建了一个jsp和servlet还有配置了一个mapping.可是我的js
- 把欠大家的20多个帖子的分都结了。轻松!!!!重新来问问题
- 如图为什么sort方法不报错
- 如何把ArrayList转为byte[]数组
- 祝大家圣诞快乐,有问题顺便求助,有事没事都来顶啊
继承了Object的方法
package java.lang.reflect;
public final
class Array { private Array() {}
public static Object newInstance(Class componentType, int length)
throws NegativeArraySizeException {
return newArray(componentType, length);
} public static Object newInstance(Class componentType, int[] dimensions)
throws IllegalArgumentException, NegativeArraySizeException {
return multiNewArray(componentType, dimensions);
}
public static native int getLength(Object array)
throws IllegalArgumentException; public static native Object get(Object array, int index)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native boolean getBoolean(Object array, int index)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native byte getByte(Object array, int index)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native char getChar(Object array, int index)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native short getShort(Object array, int index)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native int getInt(Object array, int index)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native long getLong(Object array, int index)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native float getFloat(Object array, int index)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native double getDouble(Object array, int index)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native void set(Object array, int index, Object value)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native void setBoolean(Object array, int index, boolean z)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native void setByte(Object array, int index, byte b)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native void setChar(Object array, int index, char c)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native void setShort(Object array, int index, short s)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native void setInt(Object array, int index, int i)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native void setLong(Object array, int index, long l)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native void setFloat(Object array, int index, float f)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException; public static native void setDouble(Object array, int index, double d)
throws IllegalArgumentException, ArrayIndexOutOfBoundsException;
private static native Object newArray(Class componentType, int length)
throws NegativeArraySizeException; private static native Object multiNewArray(Class componentType,
int[] dimensions)
throws IllegalArgumentException, NegativeArraySizeException;
}
如果是的话,怎么调用它的实例字段和方法呢?谢谢!
如果是的话,怎么调用它的实例字段和方法呢?谢谢!
名字很特别,好像是[I这样的
可以这样获得 (new int[2]).getClass()
byte[] a = new byte[0];
Class clz = a.getClass();
System.out.println(clz.getSuperclass());返回的是class java.lang.Object
注:不是Array类,而是int[] a=new int[3]中的数组类。
byte[] a = new byte[100];
int len = a.length;//返回长度
byte b = a[99];//返回索引为99的成员
除了Object所带的之外的其它什么属性方法你就别考虑了!!!!!!!!!!!!
在Smalltalk中几乎所有的东西,像语句块、堆栈等都是对象,
所以Java中应该绝大多数东西都是类或类的实例,好像也确实是这样。
数组类是一个由虚拟机支持的特殊类,它是由操作码newarray创建的,是Array类的实例。
一般对象是由操作码new创建的。
数组对象是由操作码newarray创建的,是Array类的实例。
好像跟newarray、Array无关的啊?
就但从这句话就可以看出Array不能再被继承,而且Array继承至Object,因此又具有Object所有方法。
这个Array类在java.lang.reflect包里。The Array class provides static methods to dynamically create and access Java arrays.
Array permits widening conversions to occur during a get or set operation, but throws an IllegalArgumentException if a narrowing conversion would occur.