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

 

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

Write a method that returns a string based on 'str' but with the first and last 'remove' number of characters removed from the string. For example, if 'str' is "ABCDEFGH" and 'remove' is 2, you would return "CDEF". As a precondition, you may assume that 'remove' is non-negative. Remove could be so big that the entire string is removed. In that case return an empty string. For example, it 'str' is "Yoda" and remove is 20, you would return "". Look at the test data for examples.


test2024_02_08_APP1SLHL_middle("Testing", 2) → "sti"
test2024_02_08_APP1SLHL_middle("remove the same number of characters from the front and back of the string", 14) → "e number of characters from the front and back"
test2024_02_08_APP1SLHL_middle("When 'remove' is a big enough number, you will return an empty string.", 44) → ""

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

public String test2024_02_08_APP1SLHL_middle(String str, int remove) { }

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

Copyright Nick Parlante 2017 - privacy