提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
返回参数,以不安全的方式强制转换为T[]类型。
/* 来 自 时代Java - N o w J a v a . c o m*/ /** * Copyright (c) 2010 Martin Geisse * * This file is distributed under the terms of the MIT license. */ //package com.nowjava; public class Main { public static void main(String[] argv) throws Exception { Object[] a = new String[] { "1", "abc", "level", null, "nowjava.com", "asdf 123" }; System.out.println(java.util.Arrays.toString(unsafeCastArray(a))); } /** * Returns the argument, cast to type T[] in an unsafe way. * @param <T> the static element type of the array type to cast to * @param a the value to cast * @return Returns the argument, cast to type T[]. */ @SuppressWarnings(