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


Please Help Members By Posting Answers For Below Questions

What does the string method compareto () do?

770


What was java originally called?

711


How do you override a variable in java?

744


I don’t want my class to be inherited by any other class. What should I do?

801


What is an abstract class and what is it’s purpose?

726


What are the 5 types of research methods?

869


How do you create a null object?

782


In java, how many ways you can take input from the console?

751


Difference between comparator and comparable in java?

853


What is static method with example?

869


What is the difference between class & structure?

795


What is the difference between super class & sub class?

804


Explain how to force the garbage collection in java.

729


What are the super most classes for all the streams?

1817


Are static members inherited to sub classes?

888