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 / anjan singh

import java.io.*;

public class Sample {

/**
* @param args
*/


public static void main(String[] args) {
// TODO Auto-generated method stub
try
{
BufferedReader br= new BufferedReader
(new InputStreamReader(System.in));
System.out.println("enter a sentence:");
String str = br.readLine();
str = str.trim();
String[] strArr = str.split(" ");
for(int i=0;i<strArr.length;i++)
for(int
j=i+1;j<strArr.length;j++)
if(strArr[j].length()
> strArr[i].length())
{
String
x=strArr[j];
strArr[j]
=strArr[i];
strArr[i]=x;
}

System.out.println("output:-");
for(int i=0;i<strArr.length;i++)
System.out.println(strArr[i]);
}
catch(Exception e){}
}

}

Is This Answer Correct ?    12 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a class object?

911


Is hashset ordered java?

1032


Have you ever used hashtable and dictionary?

974


What are autoboxing and unboxing? When does it occur?

890


Explain the overview of UDP messaging.

1077


What is the core java?

908


What is identifier in java?

1022


What is the purpose of finalization in java programming?

981


Does java support Operator Overloading?

987


What is preflight request?

940


What is constant in programming?

1028


Explain different types of thread priorities ?

1035


What is a values collection view ?

1029


What is the diffrence between inner class and nested class?

1025


How do you change an int to a string?

944