题目内容:
分析两个字符串,分别输出每个字符串的单词并统计出单词个数。阅读程序,填写空行。
注意:不改动程序结构,不得增行或删行。
import java.util.*;
public class ex2
public static void main(String args[])
String s1="I am Chinese,she is my girlfriend";String s2="Oh,really,fine";
StringTokenizer fenxi_1=new StringTokenizer(s1,",");
StringTokenizer fenxi_2=new StringTokenizer(s2,",");
int n1=fenxi_1.countTokens();
int n2=fenxi_2.countTokens();
while(fenxi_1.hasMoreTokens())
String s=fenxi_1.nextToken();
System.out.println(s);
System.out.println("s1单词:"+n1+"个");
while(fenxi_1.hasMoreTokens())
String s=______;
System.out.println(s);
System.out.println("s2单词:"+n2+"个");
参考答案:
答案解析: