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
Can we have a method name same as class name in java?
What state is a thread in when it is executing?
What are the types of strings?
Is there any way to find whether software installed in the
system is registered by just providing the .exe file?
I have tried the following code but its just displaying the
directory structure in the registry.
Here the code :
package com.msi.intaller;
import java.util.Iterator;
import ca.beq.util.win32.registry.RegistryKey;
import ca.beq.util.win32.registry.RootKey;
public class RegistryFinder {
public static void main(String... args) throws Exception
{
RegistryKey.initialize(RegistryFinder.class.getResource("jRe
gistryKey.dll").getFile());
RegistryKey key = new RegistryKey(RootKey.HKLM,
"Software\\ODBC");
for (Iterator
Is the empty set a singleton?
What are inner classes or non static nested classes in java?
How to perform quicksort in java?
What do you understand by access specifiers in Java?
Can an arraylist be empty?
What is replacefirst in java?
What is the difference between state-based unit testing and interaction-based unit testing?
What is meant by local variable and instance variable?
Explain parallel processing in java8?
What is java util collection?
Is it possible to override the main method?