package itcast;
import java.util.ArrayList;
import java.util.Iterator;
public class N {
/**
* 将List集合下包含数字的元素去掉
*/
public static void main(String[] args) {
ArrayList<String> al = new ArrayList<>();
al.add("shwujWE");
al.add("sh34ujWE");
al.add("s357wujWE");
al.add("shw778E");
al.add("sh4E");
ArrayList<String> ol = deleteNum(al);
for (String string : ol) {
System.out.println(string);
}
}
public static ArrayList<String> deleteNum(ArrayList<String> ol) {
//ArrayList<String> nl = new ArrayList<>();
Iterator<String> it = ol.iterator();
while(it.hasNext()) {
String str = it.next();
char[] arr = str.toCharArray();
for (int i = 0; i < arr.length; i++) {
if(arr[i] > '0' && arr[i] < '9') {
it.remove();
}
}
}
return ol;
}
}
|
|