Declare and initialize a reference variable for an ArrayList named codesList that stores items of type Character. Read integer numCodes from input. Then, read numCodes characters from input and insert each character into codesList, in that order. Ex: If the input is: 3 V D R then the output is: V D R
import java. util. ArrayList;
import java. util. Scanner;
public class MakeCodesList {
public static void main(String[] args) {
Scanner scnr = new Scanner(System. in) ;
int numCodes;
int i;
/* Variable declarations go here */
ArrayList codesList = new ArrayList<>() ;
/* Your code goes here */
numCodes = scnr. nextInt() ;
for (i = 0; i < numCodes; ++i) {
codesList. add(scnr. next() . charAt(0) ) ;
}
// Traversing a list using indexes
for (i = 0; i < codesList. size() ; ++i) {
System. out. print(codesList. get(i) + " ") ;
}
System. out. println() ;
}
}