Skip to main content

Practice · 1 of 3

Word statistics

CHALLENGE
Difficulty: beginner+25 XP

Implement static int wordCount(String sentence) returning the number of words (whitespace-separated, multiple spaces allowed) and static String longestWord(String sentence) returning the longest word; ties go to the FIRST longest. Empty or null input: 0 words, empty longest.

Back to lesson: Practice: Practice: Text Processing