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 is a map? What are the implementations of map?
What is complexity and its types?
What is meant by data hiding/encapsulation?
Why are constructors used?
Why is boolean important?
Name some classes present in java.util.regex package.
What's the difference between int and integer in java?
What does || mean in vectors?
What are unchecked exceptions in java?
What is final modifier?
Can a list be null in java?
Is there any case when finally will not be executed?
What is the base class for error and exception?
Can a abstract class be declared final?
Why are global variables used?