Write a java program to get a string of words and print the numbers of each word count in descending order
Answer Posted / shubhasish
public class WordCount {
private String word;
private Long wordCount;
public WordCount(String word) {
this.word = word;
}
public void displayWordCount() {
String[] temp = word.split(" ");
for (int index = temp.length - 1; index >= 0; index--) {
System.out.println(temp[index] + "-->" +
temp[index].length());
}
}
public static void main(String args[]) {
WordCount wordCount = new WordCount("I Will Crack
This");
wordCount.displayWordCount();
}
}
Is This Answer Correct ? | 12 Yes | 8 No |
Post New Answer View All Answers
What methods are used in Servlet?Applet communication?
How do you sort a set in java?
Is an integer an object?
What is the difference between JDK and JVM?
Compare java and python.
What are Normalization Rules? Define Normalization?
What do you mean by Function Overloading in java?
What is the public field modifier?
What is the difference between keyword and identifier?
what is ststic with example
What do you mean by multithreaded program?
What is the independent variable in an experiment?
How do you write a scanner class in java?
What is lambda expression in java?
What is the purpose of the wait(), notify(), and notifyall() methods in java programming?