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 access modifiers in java?

1092


Does windows 10 need java?

1099


Write code of any action class?

1058


How do you reverse a string in java without using string buffer?

1147


what is inner class in java?

1210


What’s the difference between the methods sleep() and wait()?

1064


What is an i/o filter?

1956


What is the difference between @before and @beforeclass annotation?

1190


What are the main differences between the java platform and other platforms?

1104


How to access arraylist elements in java?

1032


What are inbuilt functions?

1044


What is the protected method modifier?

1085


Explain the features of java?

1066


Describe 2 different ways to concatenate two strings.

1263


Can we access instance variables within static methods ?

1150