Question: Integer numSize is read from input. ArrayList nameValues contains numSize strings read from input. Complete the enhanced for loop to add each element in nameValues
Integer numSize is read from input. ArrayList nameValues contains numSize strings read from input. Complete the enhanced for loop to add each element in nameValues that is not equal to "Mai" to filteredNamesList.
Ex: If the input is:
Gil Rob Mai Mai Dax
then the output is:
Names that are not Mai:
Gil Rob Dax
import java.util.Scanner;
import java.util.ArrayList;
public class Names
public static void mainString args
Scanner scnr new ScannerSystemin;
ArrayList nameValues new ArrayList;
ArrayList filteredNamesList new ArrayList;
int numSize;
int i;
numSize scnrnextInt;
for i ; i numSize; i
nameValues.addscnrnext;
for String nameValue : nameValues
Your code goes here
System.out.printlnNames that are not Mai:";
for String nameValue : filteredNamesList
System.out.printnameValue ;
System.out.println;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
