I have an arraylist filled with different variables. How can I print this arraylist out to the console using the printf
flag in Java?
public class mendietaRAL {
public static void theArrayList() {
ArrayList<Object> theList = new ArrayList<Object>();
theList.add(123);
theList.add("Java");
theList.add(3.75);
theList.add("Summer C");
theList.add(2018);
for (int i = 0; i < theList.size(); i++) {
System.out.printf(theList.get(i));
}
theList.remove(1);
theList.remove(3);
System.out.println();
for (int i = 0; i < theList.size(); i++) {
System.out.printf(theList.get(i));
}
}
}