Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started