-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUseToken.java
More file actions
21 lines (21 loc) · 586 Bytes
/
Copy pathUseToken.java
File metadata and controls
21 lines (21 loc) · 586 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.util.*;
public class UseToken
{
public static void main(String[] args)
{
String str = "数学::英语::语文::化学";
StringTokenizer st = new StringTokenizer(str, "::");
System.out.println(str + "\n课程数为: " + st.countTokens());
while (st.hasMoreTokens())
{
System.out.println(st.nextToken("::"));
}
str = "Hello this is a test";
st = new StringTokenizer(str);
System.out.println(str + "\n单词数为: " + st.countTokens());
while (st.hasMoreTokens())
{
System.out.println(st.nextToken());
}
}
}