一、统计英文单词的数量
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
public class xt6 {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
String aLine,text = “”;
while((aLine=reader.readLine())!=null) {
text+=aLine;
}
// 全部转成小写
text = text.toLowerCase();
// 字符串分割
String str[] = text.split("[,.! ()]");
System.out.println("单词个数:"+str.length);
// 单词计数
Map<String, Integer> map = new HashMap<>();
for (String s : str) {
if (s.length() != 0) {
if (map.containsKey(s)) {
map.put(s, map.get(s) + 1);
} else {