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 namespace in java?
What is the use of predicate in java 8?
What is prefix of a string?
How does hashmap work in java ?
Give us a program to check for parenthesis matching using stack.
Why can't we make a class private in java?
What is == mean?
What is a singleton puppy?
How do I know if java is installed?
Can we access the non-final local variable, inside the local inner class?
What are the advantages of inner classes?
What does g mean in regex?
What is field name?
How do you ensure that n threads can access n resources without deadlock?
Is java free for businesses?