Chinaunix

标题: Java note [打印本页]

作者: zhenge10    时间: 2008-09-21 08:30
标题: Java note
how to convert Objext[] into String[] or any other
String[] str[] = (String[])list.toArray(); // won't work, as toArray() returns Object[]
String[] str[] = (String[])list.toArray(new String[0]); // works, creates a new String[]
String[] str[] = (String[])list.toArray(newString[list.size()]); // works, returns a reference to the array created inline


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/52621/showart_1211996.html




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2