Ask Question
28 December, 16:10

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.

+4
Answers (1)
  1. 28 December, 18:16
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers