Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 is default locale java?

1056


What are streams?

1067


What is float in java?

943


How do you sort in descending order in java using collections sort?

859


Is special character in java?

1061


How does linkedhashmap work in java?

952


What is the difference between post and put?

1008


Explain the use of sublass in a java program?

985


These static constructors are correct ? class A { statc intA() { } static A(int x,int y) { } static A(int x) { } }

1042


What are aggregate functions explain with examples?

1019


How can the checkbox class be used to create a radio button?

989


How you can force the garbage collection?

937


What is package private scope in java?

891


How do you empty a list in java?

933


What are actual parameters?

979