Object[] objs = new Object[3];
Object obj = objs;
objs = (Object[])obj;
另外,下文對java中的數組的本質做了一些探討:
http://dev.csdn.net/author/DeepNightTwo/afb7e220bdf5423ba656f84b6a183b44.html
另,/**//*
* TestObjectArray.java, 2007-6-16 17:07:29.
*
* CopyRight (c) 2007-2007, yethyeth ,All rights reserved.
*
* This file is licenced under the Apache License.
*
*
* this file shows that object arrays is treated as objects.
*/
package cn.yethyeth.sample;
public class TestObjectArray ...{
/** *//**
* @param args
*/
public static void main(String[] args) ...{
// TODO Auto-generated method stub
Object[] objs = new Object[2];
objs[0] = new Integer(0);
objs[1] = new Integer(1);
Object obj = (Object)objs;
Object[] objs2 = (Object[])obj;
System.out.println(objs2[1]);
int[] is = new int[2];
is[0] = 0;
is[1] = 1;
Object obj1 = (Object)is;
System.out.println(obj1);
System.out.println(obj1.getClass() );
int[] iss = (int[])obj1;
System.out.println( iss[1]);
}
}
結果:1
[I@148cc8c
class [I
1