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
What is another word for methodology?
What happens when a thread cannot acquire a lock on an object in java programming?
What is :: operator in java 8?
how to write a server program and sending the mails to the server using smtp protocol please help me
List some java keywords sun like c, c + + keywords?
Can we create more than one object singleton class?
Why do we need wrapper classes?
What is rmi and steps involved in developing an rmi object?
How to declare objects of a class ?
What are synchronized methods and synchronized statements in java programming?
what is a green thread? : Java thread
Name and explain the types of ways which are used to pass arguments in any function in java.
Which oo concept is achieved by using overloading and overriding?
What is the right data type to represent a price in java?
Give the hierarchy of inputstream and outputstream classes.