Write a java program to get a string of words and print the numbers of each word count in descending order
Answer Posted / prash
class WordCount{
public List list;
public static void main(String[] args) {
System.out.println(args[0]);
List arr = Arrays.asList(args);
Iterator it = arr.iterator();
List l = new ArrayList();
while (it.hasNext()) {
String s = (String) it.next();
System.out.println(s);
l.add(s.length());
}
Collections.sort(l);
Collections.reverse(l);
}
}
Is This Answer Correct ? | 8 Yes | 10 No |
Post New Answer View All Answers
Why is the main method declared static?
How do you execute a thread in java?
Is treeset sorted in java?
What is the size of an array?
What is an immutable class?
What is difference between array and vector?
What type of language is java?
What are bind parameters?
What is finalize()? Is finalize() similar to a destructor?
Which class represents the socket that both the client and server use to communicate with each other?
What is immutable in java?
What is meant by class loader? How many types are there? When will we use them?
What is generic type?
Why java is considered as platform independent?
Can we overload the constructors?