写一个方法,实现对字符串数组中包含a|A的所有名字输出。
public class Text7 {
public void func7() {
String[] arr4 = new String[] {"Allen","Smith","James","Martin","Ford"};
int k = 0;
for(int i = 0;i<arr4.length;i++) {
if(arr4[i].contains("a") | arr4[i].contains("A")) {
continue;
}
k++;
}
String[] arr5 = new String[(arr4.length-k)];
int x = 0;
for(int j =0; j<arr4.length;j++) {
if(arr4[j].contains("a") | arr4[j].contains("A")) {
arr5[x] = arr4[j];
x++;
}
}
for(int q = 0;q<arr5.length;q++) {
System.out.print(arr5[q]+",");
}
}
}