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
Differentiate storage classes on the basis of their scope?
Does the order of public and static declaration matter in main method?
What do you mean by thread safe?
Hi all, I am dng a mini project on FileSplitter application which splits the GBs of logfile into Smaller chunks(mbs) depending on the split size." How to handle GBs file? I am getting OutOfMemoryException, when I input such GB sized file. Thx
What is a dynamic array java?
Is singleton class immutable?
What is space character in java?
What is the difference between checked exception and unchecked exception?
Give me some null interfaces in java?
What is final modifier?
How to sort elements in a parallel array in java?
What is anti pattern in java?
What is bigger kb or mb?
What is data member in java?
What is difference between variable declaration and definition?