package newpackage; import java.util.ArrayList; public class NewClass { public static void main(String[] args) { ArrayList list = new ArrayList(5); list.add(1, "ASD"); System.out.println(list.size()); } }
whats wrong with the initialization of the arraylist object? its a basic assumption to anyone who will read the code,
a new ArrayList object is initialized with an initial capacity of 5, but why it doesnt have an initial capacity? i printed out the size of the array but the size was 0 , whats wrong?