Ask Question
13 May, 13:22

array of String objects, words, has been properly declared and initialized. Each element of words contains a String consisting of lowercase letters (a-z). Write a code segment that uses an enhanced for loop to print all elements of words that end with "ing". As an example, if words contains {"ten", "fading", "post", "card", "thunder", "hinge", "trailing", "batting"}, then the following output should be produced by the code segment.

+1
Answers (1)
  1. 13 May, 15:45
    0
    for (String s:words)

    if (s. endsWith ("ing"))

    System. out. println (s);

    Explanation:

    Create an enhanced for loop that iterates through the words array

    Check if an element in words ends with "ing" using endsWith () method (Since it is said that strings are lowercase letters, we do not need to check it)

    If you find one that ends with "ing", print the element
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “array of String objects, words, has been properly declared and initialized. Each element of words contains a String consisting of lowercase ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers