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 the string method compareto () do?
What was java originally called?
How do you override a variable in java?
I don’t want my class to be inherited by any other class. What should I do?
What is an abstract class and what is it’s purpose?
What are the 5 types of research methods?
How do you create a null object?
In java, how many ways you can take input from the console?
Difference between comparator and comparable in java?
What is static method with example?
What is the difference between class & structure?
What is the difference between super class & sub class?
Explain how to force the garbage collection in java.
What are the super most classes for all the streams?
Are static members inherited to sub classes?