id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

numWords


Write a method named numWords that receives a String passage and determines how many individual words are in the passage. you may assume that the passage has at least one word.


You will need to focus on spaces. 

numWords("apple") → 1
numWords("apple banana carrot dill") → 4
numWords("apple banana") → 2

...Save, Compile, Run (ctrl-enter)

public int numWords(String passage) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 202 Post-solution available

Copyright Nick Parlante 2017 - privacy