有字符串数组{“abced”, “efgc”, “kuyed”, “wn”, “mn”},输出所有以“a”开头的字符串。大学复习题,实在写不动了,不会写:-(
package csdn20220608;
/**
* @author wf
*/
public class ArrTest {
public static void main(String[] args) {
String[] arr = {"abced", "efgc", "kuyed", "wn", "mn"};
for (String str : arr) {
if ("a".equals(str.substring(0,1))) {
System.out.println(str);
}
}
}
}
public class Test {
public static void main(String[] args) {
String[] ss= {"abced", "efgc", "kuyed", "wn", "mn"};
for (String s: ss) {
if (s.startsWith("a"))) {
System.out.println(s);
}
}
}
}