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

Which class is the superclass for all the classes?

1062


Can list be null in java?

1096


Can we inherit inner class?

1069


What is string data type?

1012


What is a module function?

1156


What are the main uses of java?

1032


how to write a program for sending mails between client and server

2114


What is an object’s lock and which object’s have locks?

1011


Why singleton class is used in java?

1190


How does hashmap work in java ?

1102


What is complexity and its types?

1095


Can a abstract class be declared final?

1044


How objects of a class are created if no constructor is defined in the class?

1119


What are the principle concepts of oops?

1009


How do you write a scanner class in java?

1059