Skip to main content

Practice ยท 1 of 3

Word statistics

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.

Difficulty: beginner

Back to lesson: Practice: Practice: Text Processing