例:String[] str = { "Java", "C++", "Php", "C#", "Python", "C++", "Java" };
List<String> list = new ArrayList<String>(); for (int i = 0; i < str.length; i++) { if (!list.contains(str[i])) { list.add(str[i]); } }System.out.println("********");
String[] newStr = list.toArray(new String[1]); //返回一个包含所有对象的指定类型的数组 for (String elementB : newStr) { System.out.print(elementB + " "); } System.out.println("*********");