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 is default locale java?
What are streams?
What is float in java?
How do you sort in descending order in java using collections sort?
Is special character in java?
How does linkedhashmap work in java?
What is the difference between post and put?
Explain the use of sublass in a java program?
These static constructors are correct ? class A { statc intA() { } static A(int x,int y) { } static A(int x) { } }
What are aggregate functions explain with examples?
How can the checkbox class be used to create a radio button?
How you can force the garbage collection?
What is package private scope in java?
How do you empty a list in java?
What are actual parameters?