你可以把基本上所有的实例化出来的东东看成是对象,也包括数组
可以是String[] a
同样也可以做个jLabel[] b
可以是String[] a
同样也可以做个jLabel[] b
解决方案 »
- 请大家进来看看,同样的文件,为什么会报错?
- 怎么实现List中两个元素的交换???
- java如何取得当前系统的时间并转换类型
- windows自带的任务计划运行java程序跟直接双击运行java程序不能达到同一效果
- 有没有人可以给我一个可以穿越防火墙的SocketImpl的例子
- 多目录下问题.请高手说个方法------UP给分了喽
- 大家好!!!谁有java的基础书,我在网上下的都不能用!!!!
- 请高人指导:java与图像处理。
- 加载和运行
- 最新版的mac装完jdk1.8后用终端查询依旧是jdk1.6,暂时无解
- 如何把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.