Question: public static String[] wordsEndingIn(String[] list, String letter) Gets an array of all the words in the given array that contain the given letter. The comparison

public static String[] wordsEndingIn(String[] list, String letter)

Gets an array of all the words in the given array that contain the given letter. The comparison is case-insensitive. 'A' and 'a' are counted as the same letter. You will need to use Arrays.copyOf() to return an array that contains just the words ending in the letter (using enhanced loop)

 Tester:  import java.util.Arrays; /** * Tests the static methods in StuffAndThings */ public class StuffAndThingsTester { public static void main(String[] args) { //array ends in String[] empty = new String[0]; String[] answer = StuffAndThings.wordsEndingIn(empty, "e"); System.out.println("Empty array: " + Arrays.toString(answer)); System.out.println("Expected: []"); String[] words2 = {"The", "joy", "of", "code", "Java", "You", "gotta", "love", "it"}; answer = StuffAndThings.wordsEndingIn(words2, "e"); System.out.println("ends in e: " + Arrays.toString(answer)); System.out.println("Expected: [The, code, love]"); answer = StuffAndThings.wordsEndingIn(words2, "a"); System.out.println("ends in a: " + Arrays.toString(answer)); System.out.println("Expected: [Java, gotta]"); answer = StuffAndThings.wordsEndingIn(words2, "x"); System.out.println("ends in x: " + Arrays.toString(answer)); System.out.println("Expected: []"); } } 

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!