标签:text string oar arraylist next class exti scanner round
Integer 类型
ArrayList<Integer> Mlist = new ArrayList<Integer>(); Scanner scM = new Scanner(new File("D://m.txt"));
while (scM.hasNextInt()) { int i = scM.nextInt(); Mlist.add(i); }
/*将list转为数组*/ Integer[] Marray = new Integer[Mlist.size()]; Marray = (Integer[])Mlist.toArray(Marray);
String 类型
ArrayList<String> Nlist = new ArrayList<String>(); Scanner scN = new Scanner(new File("D://n.txt")); while (scN.hasNextLine()) { String i = scN.nextLine(); Nlist.add(i); }
/*将list转为数组*/ String[] Narray = new String[Nlist.size()]; Narray = (String[])Nlist.toArray(Narray);
/*数组转List*/ String[] userid = {"aa","bb","cc"}; List list = new ArrayList(Arrays.asList(userid));
标签:text string oar arraylist next class exti scanner round
原文地址:http://www.cnblogs.com/wjqboke/p/6079691.html