forked from deepdalsania/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToken.java
More file actions
37 lines (28 loc) · 816 Bytes
/
Token.java
File metadata and controls
37 lines (28 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package file;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Token {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
System.out.println("Enter any numbers : ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
StringTokenizer s1 = new StringTokenizer(s);
System.out.println("Total Tokens : "+s1.countTokens());
int count = 0;
while (s1.hasMoreElements()) {
String t = (String) s1.nextElement();
System.out.println("Token is : "+t);
if (t.contains("4")) {
count++;
}
}
System.out.println("Repeated Tokens : "+count);
}
}