20170118问题解析请点击今日问题下方的“【Java每日一题】20170119”查看(问题解析在公众号首发,公众号ID:weknow619)
package Jan2017; import java.util.Arrays;
import java.util.List; public class Ques0119 {
public static void main(String[] arg){
List<String> list = Arrays.asList("1", "2");
for (String str : toArray(list)) {
System.out.println(str);
}
} public static <T> T[] toArray(List<T> list){
T[] t = (T[]) new Object[list.size()];
for (int i = 0, s = list.size(); i < s; i++) {
t[i] = list.get(i);
}
return t;
}
}
今日问题:
请问主程序能否正常运行输出结果?(点击以下“【Java每日一题】20170119”查看20170118问题解析)
题目原发布于公众号、简书:【Java每日一题】20170119,【Java每日一题】20170119 (也可以扫描头像二维码查看)