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

 

orion.a.smith@gmail.com hcs-strings > apcsaStringsFirstFiveSearch
prev  |  next  |  chance

Given two String inputs, return the position of the first five characters of the first String within the second String, or -1 if the first five characters of the first String do not occur within the second String. Note that some of the input Strings will have less than five characters, return -1 if that happens.


HINT

This method requires the use of the length(), substring() and indexOf() methods of Strings.

apcsaStringsFirstFiveSearch("abcdefg", "abcde Blah blah") → 0
apcsaStringsFirstFiveSearch("abcdefg", "Blah blah abcde") → 10
apcsaStringsFirstFiveSearch("abc", "abc") → -1

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

public int apcsaStringsFirstFiveSearch(String one, String two) { }

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

Copyright Nick Parlante 2017 - privacy