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


Please Help Members By Posting Answers For Below Questions

What methods are used in Servlet?Applet communication?

1657


How do you sort a set in java?

513


Is an integer an object?

513


What is the difference between JDK and JVM?

627


Compare java and python.

573






What are Normalization Rules? Define Normalization?

545


What do you mean by Function Overloading in java?

622


What is the public field modifier?

542


What is the difference between keyword and identifier?

525


what is ststic with example

1589


What do you mean by multithreaded program?

546


What is the independent variable in an experiment?

544


How do you write a scanner class in java?

557


What is lambda expression in java?

536


What is the purpose of the wait(), notify(), and notifyall() methods in java programming?

572