Write a program that creates an ArrayList of ints. Then, add the first 10 odd integers to the ArrayList. Finally, print out the contents of the ArrayList.
import java.util.*;class Main { public static void main(String[] args) { List<Integer> array_list = new ArrayList<Integer>(); int x = -1; for (int i = 0; i<10; i++){ x = x+2; array_list.add(x); } System.out.println(array_list); }}
import java.util.*; class Main { public static void main(String[] args) { List<Integer> array_list = new ArrayList<Integer>(); int x = -1; for (int i = 0; i<10; i++){ x = x+2; array_list.add(x); } System.out.println(array_list); } }
import java.util.*; public class Main { public static void main(String args[]) { ArrayList<Integer> al = new ArrayList<>(); al.add(1); al.add(3); al.add(5); al.add(7); al.add(9); al.add(11); al.add(13); al.add(15); al.add(17); al.add(19); System.out.println(al); } }