You are viewing a single comment's thread. Return to all comments →
for 9th test case I had to put if condition s.length() > 0
public static void main(String[] args) { Scanner scan = new Scanner(System.in); scan.useDelimiter("\\Z"); String s = scan.next().trim(); if (s.length() > 0) { String[] tokens = s.split("[!,?._'@\\s]+"); System.out.println(tokens.length); for(String token : tokens) { System.out.println(token); } } else { System.out.println(0); } scan.close(); }
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 →
for 9th test case I had to put if condition s.length() > 0