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 the difference between a synchronized method and a synchronized block?
What is the original name of java?
Does java support multiple inheritance or not?
What is the difference between length and length() method in java?
Explain an algorithm to find depth of a binary tree.
Explain the concept of hashtables?
What is ‘is-a ‘ relationship in java?
What environment variables do I need to set on my machine in order to be able to run java programs?
What are different types of states exist for a thread?
How do you download stubs from Remote place?
Can an integer be a string?
How do you pass by reference?
What is static import in java?
What is the final keyword?
What if I write static public void instead of public static void in java?