Write a java program to get a string of words and print the numbers of each word count in descending order
Answer Posted / megha shetty
public class Inc {
public static void main(String[] args) {
// TODO Auto-generated method stub
String temp;
String s="this is my way of doing it";
String s1[]=s.split(" ");
for(int j=1;j<=s1.length-1;j++)
for(int i=0;i<s1.length-j;i++)
{
if(s1[i].length()<s1[i+1].length())
{ temp=s1[i];
s1[i]=s1[i+1];
s1[i+1]=temp;
}
}
System.out.println("
new sorted array:
");
for(String i:s1)
System.out.println(i+" the length is "+i.length());
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Is java se free?
Is list ordered in java?
What are decalarations?
What is local variable and instance variable?
Which methods are used during serialization and deserialization process?
What is the main purpose of serialization in java?
What is the latest version of java?
How to solve the problem of generating the unique hash keys with hash function?
Q1.A. Write note on “The class path Environment Variable”? B. Which are different kinds of source code? Q2.A. How to create an interface? B. Why convert an applet to an application? Q3.A. How to use Media tracker Class. B. How to use string tokenizer class. Q4 A. Explain the overview of UDP messaging. B. Difference between SQL Exception class and SQL Warning class. Q5. A. How to create com object in Java? B. Write short notes on “The properties class” Q6. A. When object is created and destroyed? B. Explain the JDB in depth & command line. C. Write short notes on Web Sites.
What is the maximum size of list in java?
What is the difference between an object-oriented programming language and object-based programming language?
What is the difference between the font and fontmetrics classes in java programming?
Explain about narrowing conversion in java?
What does math floor () do?
What is an 8 bit word?