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
What are the benefits of java?
State differences between C and Java?
What is substring in java?
Can you tell me range of byte?
What are the topics in core java?
What is oops in java?
What are the restrictions imposed on method overriding?
Using callable statement how can you pass out parameters, explain with example?
What is constant in programming?
why would you use a synchronized block vs. Synchronized method? : Java thread
What causes memory leak in java?
How can we make a class virtual?
What are the advantages of encapsulation in java?
Explain the importance of import keyword in java?
How to Sort Strings which are given in List and display in ascending order without using java api.