What is the output of the following?
import java.util.Arrays; import java.util.List; public class Main { public static void main(String[] args) { List<String> v = Arrays.asList("can", "cup"); for (int c = 0; c < v.size(); c++) System.out.print(v.get(c) + ","); }//from www . ja v a 2 s. co m }
A.
This is a correct loop to go through an ArrayList or List starting from the beginning.
It starts with index 0 and goes to the last index in the list.
Option A is correct.