Java分析字符串功能
package Date;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Test {
public static void main(String[] args) {
System.out.println("请输入需分析的字符串:");
Scanner scanner=new Scanner(System.in);
String str=scanner.nextLine();
StringTokenizer tokenizer=new StringTokenizer(str);
int number=tokenizer.countTokens();
String temp=null;
while(tokenizer.hasMoreTokens()){
temp=tokenizer.nextToken();
System.out.print(temp+"\t");
}
System.out.println("\n"+str+"字符串共有"+number+"个语言符号。");
}
}