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

 

sspiege3@schools.nyc.gov > countWords
prev  |  next  |  chance

For this method, you are given a sentence as a parameter. Count the number of words in the sentence. You may assume that each word is separated by only one space and each string has at least one word.


countWords("Wow!") → 1
countWords("She is awesome.") → 3
countWords("This class is excellent.") → 4

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

public int countWords(String sentence){ }

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: 200

Copyright Nick Parlante 2017 - privacy