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. fading trailing batting Write the code segment as described above. The code segment must use an enhanced for loop to earn full credit.

Respuesta :

Answer:

 public static void main(String[] args) {

   String ing[] = {"ten","fading","post","card","thunder","hinge","trailing","batting"};

   for (String i: ing){

     if (i.endsWith("ing")){

       System.out.println(i);

    }

   }

 }

Explanation:

The for-loop cycles through the entire list and the if-statement makes it so that the string is only printed if it ends with "ing"

The program is an illustration of loops.

Loops are used to perform repetitive and iterative operations.

The code segment in Java where comments are used to explain each line is as follows:

//This iterates through the array elements

for (String elem: myArr){

   //This checks if the current array element ends with "ing"

   if (elem.endsWith("ing")){

       //If yes, the array element is printed

       System.out.println(elem);

   }

}

Read more about similar programs at:

https://brainly.com/question/15684709