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 / ruchira

import java.util.StringTokenizer;

public class NumberOfWords {

/**
* to get a string of words and print the numbers of
each word count in descending order

*/
public static void main(String[] args) {
String str = "Save water";

System.out.println(str);
StringTokenizer st = new
StringTokenizer(str," ");
int i = 0;
i=st.countTokens();
while (i>0)
{
System.out.println(i);
i --;
}
}
}

Is This Answer Correct ?    12 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the benefits of java?

1095


State differences between C and Java?

1153


What is substring in java?

1139


Can you tell me range of byte?

950


What are the topics in core java?

1013


What is oops in java?

963


What are the restrictions imposed on method overriding?

969


Using callable statement how can you pass out parameters, explain with example?

1177


What is constant in programming?

1037


why would you use a synchronized block vs. Synchronized method? : Java thread

905


What causes memory leak in java?

890


How can we make a class virtual?

1069


What are the advantages of encapsulation in java?

962


Explain the importance of import keyword in java?

958


How to Sort Strings which are given in List and display in ascending order without using java api.

4352