使用java语言编写代码给定一个由英文字符、数字、空格和英文标点符号组成的字符串长度不超过2000请将其切分为单词要求去掉所有的非英文字母然后将单词全部转换成小写再按照字典序升序排列每个单词之间用空格分隔。例如有文本:Python was created in 1990 by Guido at Centrum CWI see httpwwwcwinl in the Netherlands处理完成之
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
String[] words = str.split("[^a-zA-Z]+"); // 利用正则表达式分割字符串
List
原文地址: https://www.cveoy.top/t/topic/bD2w 著作权归作者所有。请勿转载和采集!