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.
Trim the string before processing otherise it will failed the test cases 10-to rest.
publicclassSolution{publicstaticvoidmain(String[]args){Scannerscan=newScanner(System.in);Strings=scan.nextLine();// Write your code here.scan.close();s=s.trim();String[]token=s.split("[^A-Za-z]+");if(s.isEmpty()){System.out.println(0);return;}else{System.out.println(token.length);}for(Stringstring:token){System.out.println(string);}}}
Cookie support is required to access HackerRank
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 →
Trim the string before processing otherise it will failed the test cases 10-to rest.