Question: Complete the getMiddle method that gets the middle character from a word if the word length is odd, or the middle character pair if it

Complete the getMiddle method that gets the middle character from a word if the word length is odd, or the middle character pair if it is even. For example, getMiddle("Java")returns "av". If the word is empty, return the empty string. If it is null, return null.

Complete the following file:

public class Words { /** Gets the middle character or character pair from this word when possible. @param word a word @return the middle character (if the word length is odd) or middle two characters (if it is even), or the empty string if the word is empty, or null if it is null. */ public String getMiddle(String word) { // your work here

} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!