X455: Exception Handling - Third Letter

Create a method that returns the third character from the String word. Be sure to use a try catch block and use the appropriate exception to deal with indexes out of a String’s bound: StringIndexOutOfBoundsException. Return the character 'x' (lowercase) when this exception is caught. Do not use if statements and do not use the general exception handler Exception.

Examples:

thirdLetter("test") -> 's'

Your Answer:

Feedback

Your feedback will appear here when you check your answer.