???????дJava?????У?????????????????????Щ????????????Щ???????????????????????????????Щ???????????????£?
????1.?ж?????{"a"??"b"??"c"??"d"}????????"a"???????′??????????????????????????ifcontainsByArrays??????÷????????????Щ??

 

public static void main(String[] args) {
String [] strs = {"a"??"b"??"c"??"d"};
Test t = new Test();
System.out.println(t.ifcontains(strs?? "a"));
System.out.println(t.ifcontainsByArrays(strs?? "a"));
}
public boolean ifcontains(String [] strs?? String str) {
for (String s : strs) {
if (s.equals(str)) {
return true;
}
}
return false;
}
public boolean ifcontainsByArrays(String [] strs?? String str) {
// ???Arrays.asList()??????????? java.util.Arrays.ArrayList??????java.util.ArrayList
return Arrays.asList(strs).contains(str);
}

????2.??????????????б??е??????????′???????????removeByIterator????????????????????μ?list??

 

public static void main(String[] args) {
List<String> list = new ArrayList<String>(Arrays.asList("a"?? "b"?? "c"?? "d"));
List<String> list1 = new ArrayList<String>(Arrays.asList("a"?? "b"?? "c"?? "d"));
Test1 t = new Test1();
for (String s : t.removeByIterator(list?? "c")) {
System.out.print(s);
}
System.out.println();
System.out.println("----------------------------");
for (String s : t.removeByNewList(list1?? "c")) {
System.out.print(s);
}
}
public List<String> removeByNewList(List<String> list?? String str) {
List<String> newList = new ArrayList<String>();
for (String s : list) {
if (!s.equals(str)) {
newList.add(s);
}
}
return newList;
}
public List<String> removeByIterator(List<String> list?? String str) {
Iterator<String> iterator = list.iterator();
while (iterator.hasNext()) {
String s = iterator.next();
if (s.equals(str)) {
// ?????????????????
iterator.remove();
}
}
return list;
}

??????????о????????????????????