Skip to main content

Practice · 5 of 5

indexOf, twice

CHALLENGE
Difficulty: intermediate+25 XP

Implement boolean occursOnce(String text, String word): true when word appears in text exactly once. Use indexOf twice — the second call needs the start index form.

Back to lesson: Practice: String lab