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 module in project?
What are the application of stack?
In a container there are 5 components. I want to display the all the components names, how will you do that one?
What are use cases?
What are the different collection views provided by maps?
Difference between default and protected access specifiers?
What do you mean by default constructor in java?
How does the garbage collector works in java?
Is 0 a prime number?
What are exception handling keywords in java?
what is the purpose of the runtime class?
What is java virtual machine and how it is considered in context of java’s platform independent feature?
Is math class static in java?
What is the maximum size of arraylist in java?
What class allows you to read objects directly from a stream in java programming?