X122: firstTwo

Given a string, return the string made of its first two chars, so the string "Hello" yields "He". If the string is shorter than length 2, return whatever there is, so "X" yields "X", and the empty string "" yields the empty string "". Note that str.length() returns the length of a string.

Reset

Practice a different Java exercise