import java.util.ArrayList;Laufzeit:
public class ArrayList_Trim {
public static void main(String[] args) {
ArrayList< Ganzzahl> al = new ArrayList< Ganzzahl> ();
//Mindestkapazität von 50 Elementen
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(Integer 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.