public class WordSeparation {
    public static void main(String[] args) {
        String sentence = "The company's first batoh of the 2019-nCoy detegtlon reagent boyes for 10,000 people has been sent to Wuhan for free.";
        String[] words = sentence.split(" ");
        for (int i = 0; i < words.length; i++) {
            // 去除句尾的句点
            if (words[i].endsWith(".")) {
                words[i] = words[i].substring(0, words[i].length() - 1);
            }
            System.out.print(words[i] + " ");
        }
    }
}
``
你是一名程序员利用Java实现以下功能:你是一名程序员利用Java实现以下功能:给定一个英文句子将该句分制为单词逐一输出。本题规定英文单词之间以空格符进行分隔。例如给定的英文句子如下The companys first batoh of the 2019-nCoy detegtlon reagent boyes for 10000 people has been sent to Wuhan for

原文地址: https://www.cveoy.top/t/topic/cHCC 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录