You are viewing a single comment's thread. Return to all comments →
solution with all test cases passed import java.io.; import java.util.;
public class Solution {
public static void main(String[] args) { Scanner scan = new Scanner(System.in); String s = scan.nextLine(); // Write your code here. scan.close(); if (s.isEmpty() || s==null) { System.out.println(0); } if (s.length()>1 && s.length()<400000) { String news = s.trim(); if(news.length()>0){ String arr[] = news.split("[\\s!,?._'@]+"); int n=arr.length; System.out.println(n); for (int i = 0; i < n; i++) { System.out.println(arr[i]); } } else { System.out.println(0); } }else{ System.out.println(0); } }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Java String Tokens
You are viewing a single comment's thread. Return to all comments →
solution with all test cases passed import java.io.; import java.util.;
public class Solution {
}