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

 

crehwinkel@frhsd.com ap-exam-review-set3 > countWords
prev  |  next  |  chance

Write a method named countWords that accepts a string as its parameter and returns the number of words in it. A word is a sequence of one or more non-space characters. For example, the call of countWords("What is your name?") should return 4.


countWords("Hello") → 1
countWords("What is your name?") → 4
countWords("There are 10 types of people in the world: those who understand binary, and those who don't.") → 17

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

public int countWords(String str){ }

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