import java.util.ArrayList;런타임:
public class ArrayList_Trim {
public static void main(String[] args) {
ArrayList< 정수> al = 새로운 ArrayList< 정수> ();
//최소 50개 요소 용량
al.ensureCapacity(50);
al.add(1);
al.add(2);
al.add(3);
al.add(4);
al.add(5);
al.add(6);
al.add(7);
al.add(8);
al.add(9);
al.add(10);
al.trimToSize();
System.out.println(al.size());
for(정수 n:al)
System.out.println(n);
}
}
10
1
2
3
4
5
6
7
8
9
10
Please disable your ad blocker and refresh the window to use this website.