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

 

String-1 > twoChar
prev  |  next  |  chance

Given a string and an index, return a string length 2 starting at the given index. If the index is too big or too small to define a string length 2, use the first 2 chars. The string length will be at least 2.


twoChar("java", 0) → "ja"
twoChar("java", 2) → "va"
twoChar("java", 3) → "ja"

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

public String twoChar(String str, int index) { }

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

Copyright Nick Parlante 2017 - privacy