- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString_Tokens.java
More file actions
Latest commit
24 lines (22 loc) · 791 Bytes
/
Copy pathString_Tokens.java
File metadata and controls
24 lines (22 loc) · 791 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
importjava.io.*;
importjava.util.*;
publicclassSolution {
publicstaticvoidmain(String[] args) {
Scannerscan = newScanner(System.in);
Strings = scan.nextLine();
// Write your code here.
s = s.trim();//if there is any trailing spaces..
if(s.length()==0) //if the string is zero
{
System.out.println(0); //number of tokens will be zero..
return; //return nothing..
}
StringC[] = s.split("[^A-Za-z]+"); //split it if any non alphabetical characters are found..
System.out.println(C.length); //printing the number of tokens...
for(inti=0;i<C.length;i++)
{
System.out.println(C[i]); //printing the tokens..
}
scan.close();
}
}