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 the difference between checked exception and unchecked exception?
What is listnode in java?
Is java developer a good career?
What is array class in java?
When should we create our own custom exception classes?
What is udp in java?
What restrictions are placed on method overriding?
explain the difference between jdk and jvm?
What about abstract classes in java?
What does += mean coding?
What does 3 dots mean in java?
Name and explain the types of ways which are used to pass arguments in any function in java.
Can private class be inherited in java?
What is the difference between Java Program Constructor and Java Program Method, What is the purpose of Java Program constructor Please Explain it Breafily?
Explain the scope of a variable.