WAP in java to enter any sentence and display the longest and shortest word.
Use String Tokenizers.
Answers
Answered by
2
- boolean hasMoreTokens( ) - checks if there are any further tokens/words accessible.
- String nextToken( ) - returns the succeeding token/word from the String passed.
- Accepting the sentence using the Scanner class.
- Processing the sentence as specified by the question using the StringTokenizer class.
- Finding smallest and longest words by comparing the length of each word.
- Displaying the results.
Attachments:
Similar questions