String[] userid = {"aa","bb","cc"};List userList = new ArrayList();Collections.addAll(userList, userid);
String[] userid = {"aa","bb","cc"};List userList = Arrays.asList(userid);另:Arrays.asList()返回一个受指定数组支持的固定大小的列表。所以不能做Add、Remove等操作。List list = new ArrayList(Arrays.asList(userid));这样操作就可以了。
最笨的方法:String[] userid = {"aa","bb","cc"};List userList = new ArrayList(userid.length);for(String uid: userid){userList.add(uid);}
List strList = new ArrayList();strList.add("aa");strList.add("bb");Object[] objs = strList.toArray();--------------如果要变成String数组,需要强转类型。String[] strs = (String[]) strList.toArray(new String[0]);-----------------也可以指定大小:String[] strs = strList.toArray(new String[strList.size()]);
笨方法:List strList = new ArrayList();strList.add("aa");strList.add("bb");String[] strs = new String[strList.size()];