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

Is age discrete or continuous?

1126


Difference between stack and queue?

1070


What is the default size of load factor in hashing based collection?

1043


Explain covariant method overriding in java.

1100


What is package private scope in java?

935


What is the difference between a vector & an array list?

1159


what is the role of xml in core java?? and how we can use it?? can somebody give a sample program with explanation and from where i can read more about xml?????

2260


What is a subsequence of a string?

1056


What are untrusted applets?

1134


Can we assign null to double in java?

1008


What are the types of arrays in java?

1078


Why is string class considered immutable?

1044


What is e java?

1093


What is the difference between a switch statement and an if statement?

1086


Why is whitespace important?

1077