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
Is 0 an irrational number?
What is unsigned char?
What happens if I remove static from main method?
Is java hashset ordered?
Explain the difference between intermediate and terminal operations in java8?
What are the high-level thread states in java programming?
how its run?
What is an interface in java?
How to convert string to char and vice versa?
What is the purpose class.forname method?
Explain about version control?
What is final, finally, finalize?
Is ++ operator thread-safe in java?
Explain different ways of creating a thread?
Which way a developer should use for creating thread, i.e. Sub classing thread or implementing runnable.