split方法的应用和去除list中相同的元素【转】
public class testJava {
?public static String[] ss = new String[20];
//测试 split 方法
/*?public SplitDemo() {
??String s = "Thewwwwwwww,uuuuuu,";
??// 在每个空格字符处进行分解。
??ss = s.split(",");
?}
?public static void main(String[] args) {
??SplitDemo demo = new SplitDemo();
??for (int i = 0; i < ss.length; i++)
???System.out.println(ss[i]);
??
??List<Integer> entiIDLst;//= new ArrayList<Integer>();
??System.out.println(entiIDLst);
?}*/
?
//取出list中相同的元素?
?public static List removeaSameelement(List list) {
??Set set = new HashSet();
??List newList = new ArrayList();
??for (Iterator iter = list.iterator(); iter.hasNext();) {
???Object element = iter.next();
???if (set.add(element))
????newList.add(element);
??? }
??return newList;
?}
?
?public static void main(String[] args) {
??List lst=new ArrayList();
??lst.add(1);
??lst.add(1);
??lst.add(3);
??lst.add(3);
??System.out.println(removeaSameelement(lst));
??
?}
}