What will be the output of the program?
import java.util.*;
public class Sketch21
{
public static void main(String[] args)
{
int[] raw = {1, 2, 3};
System.out.println(Arrays.asList(raw).size());
}
}
Answer: A
asList takes a varargs parameter of a reference type, and int[] is itself an object rather than an array of objects, so the whole array becomes a single element. The list holds one int[] and its size is 1. An Integer[] would have been spread into three elements.
Please log in or register to report this question.