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
What does \ mean in regex?
When is the arraystoreexception thrown?
How do generics work in java?
What comes to mind when someone mentions a shallow copy in java?
What is a java string?
What are the features of junit?
What is stringbuffer in java?
Is java a pure object oriented language?
Is java se open source?
what is meant by Garbage collection?
What is bean? Where it can be used?
How do you sort data in java?
If we don’t want some of the fields not to serialize how to do that?
Why do we need hashset in java?
How do you compare arrays in java?