Write a java program to get a string of words and print the numbers of each word count in descending order

Answer Posted / surya

public class WordCount {

public static void main(String[] args) {
String string="I got a simple solution";
String[] temp=string.split(" ");
for (int i = temp.length-1; i >=0 ; i--) {
System.out.println(temp[i]+ "-->"+temp[i].length());
}
}
}

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Differentiate between the constructors and methods in java?

499


What is the difference between Java and C++?

610


What are class members by default?

653


What is math exp in java?

542


how to open and edit XML file in Weblogic???

1541






What is the difference between form & report?

584


Difference between static and dynamic class loading.

575


Define interface in java?

603


Does treeset use compareto?

533


How many bytes is double?

543


What is meant by structural programming?

547


What is difference between ++ I and I ++ in java?

524


Define immutable object?

575


How do you create a bulleted list?

557


What are instance variables?

602