//package com.nowjava;
/* from
时 代 J a v a 公 众 号 - N o w J a v a . c o m*/
import java.lang.reflect.Array;
public class Main {
public static void main(String[] argv) throws Exception {
Object array = "nowjava.com";
System.out.println(copyArray(array));
}
/**
* Returns a copy of the specified array. If <i>array</i>
* is not an array, the object itself will be returned.
* Otherwise a copy of the array will be returned. The components
* themselves are not cloned.
* @param array the array
* @return the copy of the array
*/
public static Object copyArray(Object array) {
/**
* 时 代 J a v a 公 众 号 - nowjava.com 提 供
**/
if (!array.getClass().isArray())
return array;
Class componentType = array.getClass().getComponentType();
int length = Array.getLength(array);
Object copy = Array.newInstance(componentType,
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。