Write a complete Java program called Parser that gets a comma-delimited String of integers (eg "4,8,16,32,...") from the user at the command line and then converts the String to an ArrayList of Integers using the wrapper class) with each element containing one of the input integers in sequence.
Finally, use a for loop to output the integers to the command line, each on a separate line.
import java.util.ArrayList; import java.util.Iterator; import java.util.Scanner;
public class probset5a {
public static void main(String[] args) {
ArrayList mylist = new ArrayList<>();
Scanner in = new Scanner(System.in);
System.out.println("Enter Input String : ");
String inputString = in.nextLine();
while(true) {
int index = inputString.indexOf(",");
if(index == -1) {
mylist.add(Integer.parseInt(inputString));
break;
}
mylist.add(Integer.parseInt(inputString.substring(0, index)));
inputString = inputString.substring(index + 1);
}
System.out.println("Entered Integers are : ");
Iterator i = mylist.iterator();
for(; i.hasNext()
; ) {
System.out.println(i.next());
} } }