import java.util.*; class wordFrequency{ public static void main(String args[]){ String paragraph= "ab bc ab bc abbbb bc ab cd ef bc bc "; String eachWord[]=paragraph.split(" "); ArrayListlistEachWord = new ArrayList (Arrays.asList(eachWord)); LinkedHashMap numeach=new LinkedHashMap (); for(int i=0;i<eachWord.length;i++){ numeach.put(eachWord[i],Collections.frequency(listEachWord,eachWord[i])); } System.out.println(numeach); }}
Master Core Java, JSP, Servlet, Hibernate, Maven, Spring, and more with our comprehensive tutorials and guides. Start learning today!
Comments
Post a Comment