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

public static void main(String[] args) {
String word = "get the count and arrange in descending order";
String[] temp = word.split(" ");
for (int index = 0; index < temp.length; index++) {
for (int i = index+1; i < temp.length; i++) {
if (temp[i].length() > temp[index].length()) {
String word2 = temp[i];
temp[i] = temp[index];
temp[index] = word2;
}
}
System.out.println(temp[index] +" " +temp[index].length());
}
}

Is This Answer Correct ?    28 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is age discrete or continuous?

1144


Why are there no global variables in java?

1045


How hashmap increases its size in java?

991


What is meant by attribute?

1127


What are the four corner stones of oop?

1040


What steps are taken when the OS shifts from one-thread execution to another?

1368


What is bifunction in java?

1208


What is the difference between overriding and overloading in OOPS.

1166


Is null in java?

1021


Differentiate between stringbuffer and stringbuilder in java.

1031


What is the purpose of final keyword and when to use it?

1005


What is a vector in java?

1037


What is the difference between java applets and applications?

1165


Which is the class in java?

1058


What is substring in java?

1230