-
What is the output of this program?
import java.util.*;
public class Output
{
public static void main(String args[])
{
ArrayList object = new ArrayList();
object.add("Y");
object.add("O");
object.add("U");
object.ensureCapacity(3);
object.trimToSize();
System.out.println(object.size());
}
}
-
- 0
- 1
- 2
- 3
- None of these
Correct Option: D
trimTosize() is used to reduce the size of the array that underlines an ArrayList object.