[Solved] Which of the following is the correct syntax to declare an ArrayList in Java?

Which of the following is the correct syntax to declare an ArrayList in Java?

a) ArrayList al = new ArrayList();
b) ArrayList al = new ArrayList[];
c) ArrayList al() = new ArrayList();
d) ArrayList al[] = new ArrayList[];

Answer: a
Explanation: This is a non-generic way of creating an ArrayList.

Comments