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
Why is method overloading not possible by changing the return type in java?
Enlist few advantages of inheritance?
What is an example of declaration?
What are some characteristics of interference class?
What is the method to expand and collapse nodes in a jtree?
What are static blocks in java ?
os is developed in c no java is more secured then c na why dont the os developed is developed using java
What is class forname?
How we can make copy of a java object?
What are the new features in java 8?
Name the components that are termed to be Heavy-weight component but available in Light-weight components?
Can a class have a static inner class?
What types of index data structures can you have in java?
What is the concept of multithreading?
What is anagram of a string?