We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Java
- Strings
- Java String Tokens
- Discussions
Java String Tokens
Java String Tokens
Sort by
recency
|
1691 Discussions
|
Please Login in order to post a comment
My you like this one
String tokens[] = s.split("[!,?._'@ ]+");
System.out.println(Arrays.stream(tokens).filter(token->token.length()>0).count());
Arrays.stream(tokens).filter(token->token.length()>0).forEach(token-> System.out.println(token));
This is another way(most common way I have seen so far)
import java.util.Scanner;
public class TokenStringAnotherSolution{ public static void main(String[] args) { Scanner scan = new Scanner(System.in);
}
Easiest way to handle this task!!!!!!
import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern;
public class Solution{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); String s = scan.nextLine(); scan.close();
}