import java.util.ArrayList;
import java.util.Scanner;
public class DemoStringScannner {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
ArrayList list = new ArrayList();
for (int i = 0; i 122) { //判断这些字符是否在小写字母范围内,不符合条件的从集合中删除
if (j == list.get(i).length() - 1) {
list.remove(i);
}
}
}
}
else{
list.remove(i);
}
}
String longest = list.get(0);
for (int k = 1; k longest.length()) {
longest = list.get(k);
}
}
System.out.println("符合条件的且最长的字符串为:" + longest);
}
}

/*另外可扩展一下,当两个或多个长度相等的时候的这种情况,有点懒,不是很想打QAQ,循环判断嵌套有点多,毕竟我也只是18级新生 多多体谅*/