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

 

jebbert@volusia.k12.fl.us > locateSubStr123
prev  |  next  |  chance

Write a method that accepts two string input parameters. 'orig' is the original string and 'sub' is the substring to find in the original string. Return the LAST occurance of 'sub' within 'orig' or if 'sub' does not occur in 'orig' return -1. Note that 'sub' will NOT be longer than 'orig' and neither string will be empty. You may only use the following string methods in solving this problem: .length .substring .equals .charAt


locateSubStr123("Run for the hills, run for your life!", "o") → 28
locateSubStr123("I cannot understand why this would be difficult", "I") → 0
locateSubStr123("This is a test to see what is right", "is") → 27

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

public int locateSubStr123(String orig, String sub) { }

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

Copyright Nick Parlante 2017 - privacy