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

 

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

Write a method that returns the character at a specific position 'pos' in the string 'str'. For example, if 'str' was "Wonderful" and 'pos' was 3, you would return "d" because that is the character in position 3. Remember that the character positions in strings start at zero, which is why "d" is at position 3. If 'pos' indicates a position beyond the end of the string 'str', you simply return "none" to say that there is no character in that position. As a precondition you may assume that 'pos' is not negative. The string 'str' can be any length. It can even be an empty string! Look at the test data for examples.


test2022_10_13_APP1SLHL_getSpecificCharacter("", 1) → "none"
test2022_10_13_APP1SLHL_getSpecificCharacter("", 0) → "none"
test2022_10_13_APP1SLHL_getSpecificCharacter("Eat healthy food!", 16) → "!"

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

public String test2022_10_13_APP1SLHL_getSpecificCharacter(String str, int pos) { }

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

Copyright Nick Parlante 2017 - privacy