本帖最后由 747437484 于 2013-12-29 21:27 编辑
package com;
import java.util.List;
import java.util.ArrayList;
public class test1 {
public static void main(String [] args) {
testA();
}
//去掉数组中重复的值
public static void testA() {
int [] str = {1,2,3,4,1,2};
for (int elementA:str ) {
System.out.print(elementA + " ");
}
List<String> list = new ArrayList<String>();
for (int i=0; i<str.length; i++) {
if(!list.contains(str)) {
list.add(str); //这不通过
}
}
System.out.println(list);
}
}
|