package com.heima.test;
import java.util.ArrayList;
import java.util.ListIterator;
public class Test9 {
public static void main(String[] args) {
//编写方法public void deleteNum(ArrayList<String> list){}凡是list成员包含0-9的删除
ArrayList<String> list = new ArrayList<String>();
list.add("abce0fgh");
list.add("ab2e0fgh");
list.add("ab3e0fgh");
list.add("ab5e0fgh");
list.add("ab6e0fgh");
list.add("ab5e0f8gh");
list.add("000234ab5e0f8g9h");
list.add("abc");
list.add("def");
list.add("ghi");
//demo1(list);
// Iterator it = list.iterator();
ListIterator<String> it = list.listIterator();
while (it.hasNext()) {
String s = (String)it.next();
char[] arr = s.toCharArray();
for (int i = 0; i < arr.length; i++) {
if (arr[i]<='9' && arr[i]>='0') {
// it.remove();
it.remove();
break;
}
}
}
System.out.println(list);
}
}
|
|