156k views
3 votes
How do I find the shortest word in Java?

User Chaooder
by
7.0k points

1 Answer

5 votes

Answer:

split string into words then, compare length of each word with variables small and large

Step-by-step explanation:

One of the approach to find smallest and largest word is to split string into words then, compare length of each word with variables small and large. If length of a word is less than length of small then, store that word in small. If length of a word is greater than length of large then, store that word in large.

User DvixExtract
by
8.5k points