码迷,mamicode.com
首页 > 编程语言 > 详细

Java中List转数组,必须带个参数

时间:2016-04-23 01:43:26      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:

    public static void main(String[] args) {
        List<String> lst = new ArrayList();
        lst.add("赵云 ");
        lst.add("张飞");
        //X: String[] strA = (String[]) lst.toArray();
        // List转数组:toArray(必须带个参数)
        String[] strA = (String[]) lst.toArray(new String[0]);
        for (String s : strA) {
            System.out.println(s);
        }
    }

 

Java中List转数组,必须带个参数

标签:

原文地址:http://www.cnblogs.com/AndyHoo/p/5423452.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!