Write a java program to get a string of words and print the numbers of each word count in descending order

Answer Posted / surya

public class WordCount {

public static void main(String[] args) {
String string="I got a simple solution";
String[] temp=string.split(" ");
for (int i = temp.length-1; i >=0 ; i--) {
System.out.println(temp[i]+ "-->"+temp[i].length());
}
}
}

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between break and continue statements?

820


why Java does not support multiple inheritances?

938


What is nullpointerexception?

775


Explain the inheritance?

782


Where we write javascript code in html page?

821


If I only change the return type, does the method become overloaded?

744


What are the types of sockets in java?

772


How to compare strings in java?

713


What is the structure of java?

770


What does split function do in java?

770


How do you use compareto in java?

758


What are methods and how are they defined?

898


What are the java ide's? Explain

755


How do I get the | symbol on my keyboard?

800


Can java program run without jre?

798