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

Java > String-2 > getSandwich
prev  |  next  |  chance

A sandwich is two pieces of bread with something in between. Return the string that is between the first and last appearance of "bread" in the given string, or return the empty string "" if there are not two pieces of bread.

getSandwich("breadjambread") → "jam"
getSandwich("xxbreadjambreadyy") → "jam"
getSandwich("xxbreadyy") → ""

...Save, Compile, Run

See also Java Example Code. Java help docs: If Boolean Logic | Strings | While and For Loops | Arrays and Loops


prev  |  next  |  chance   |  CodingBat  >  String-2

Forget It! -- delete my code for this problem 245.0

Copyright Nick Parlante 2006-10 - privacy