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

 

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

Write a method that returns the middle part of a string. The middle part is either the character in the middle of the string if it has an odd number of characters, or the middle two characters if the string has an even number of characters. Look at the test data for examples. You may assume that the input parameter string will have at least one character (no empty strings).


jan11_2016_APSLHLmiddleString("x") → "x"
jan11_2016_APSLHLmiddleString("ab") → "ab"
jan11_2016_APSLHLmiddleString("test") → "es"

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

public String jan11_2016_APSLHLmiddleString(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: 280

Copyright Nick Parlante 2017 - privacy