对于数组实例来说,其类型是由JVM在运行期动态生成的,表示为:[L元素类名
动态生成的类型,其父类型就是Object
并且new数组时,数组元素的类并不会被初始化
助记符:
anewarray:表示创建一个引用类型的(如类,接口,数组)数组,并将其引用值压入栈顶
newarray:表示创建一个指定的原始类型(如int,float,char)数组,并将其引用值压入栈顶
下面是代码演示:
public class MyTest4 {
public static void main(String[] args) {
MyParent4[] myParent4s=new MyParent4[1];
System.out.println(myParent4s.getClass());
MyParent4[][] myParent4s1=new MyParent4[1][1];
System.out.println(myParent4s1.getClass());
System.out.println(myParent4s.getClass().getSuperclass());
System.out.println(myParent4s1.getClass().getSuperclass());
int[] ints =new int[1];
System.out.println(ints.getClass());
System.out.println(ints.getClass().getSuperclass());
char[] chars =new char[1];
System.out.println(chars.getClass());
boolean[] booleans=new boolean[1];
System.out.println(booleans.getClass());
short[] shorts=new short[1];
System.out.println(shorts.getClass());
byte[] bytes=new byte[1];
System.out.println(bytes.getClass());
}
class MyParent4{
static {
System.out.println("myparent4 static block");
}
输出结果: