Write a java program to get a string of words and print the numbers of each word count in descending order
Answer Posted / ruchira
import java.util.StringTokenizer;
public class NumberOfWords {
/**
* to get a string of words and print the numbers of
each word count in descending order
*/
public static void main(String[] args) {
String str = "Save water";
System.out.println(str);
StringTokenizer st = new
StringTokenizer(str," ");
int i = 0;
i=st.countTokens();
while (i>0)
{
System.out.println(i);
i --;
}
}
}
| Is This Answer Correct ? | 12 Yes | 3 No |
Post New Answer View All Answers
Is age discrete or continuous?
Difference between stack and queue?
What is the default size of load factor in hashing based collection?
Explain covariant method overriding in java.
What is package private scope in java?
What is the difference between a vector & an array list?
what is the role of xml in core java?? and how we can use it?? can somebody give a sample program with explanation and from where i can read more about xml?????
What is a subsequence of a string?
What are untrusted applets?
Can we assign null to double in java?
What are the types of arrays in java?
Why is string class considered immutable?
What is e java?
What is the difference between a switch statement and an if statement?
Why is whitespace important?