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
Which graphs are functions?
How do you input a string in java?
What is a line break?
how to create constants in java?
How do you sort arrays in java?
Is set sorted in java?
List types of storage classes in java?
How arrays are stored in memory in java?
What is finally in Java?
If goto and const is reserve words than why it is not work in java?
How much ram can a 64 bit processor theoretically?
Give few difference between constructor and method?
Why vector is used in java?
What are the types of literals?
What is the exact difference in between Unicast and Multicast object? Where will it be used?