ListÀÇ »ý¼º
TestArrayList.java
import java.util.*;
public class TestArrayList {
public static void main(String args[]) {
List al = new ArrayList();
Integer three = new Integer(3);
al.add(new Integer(0));
al.add(new Integer(1));
al.add(new Integer(2));
al.add(three);
al.add(new Integer(4));
System.out.println("The capacity of al is " + al.size());
System.out.println("al now contains " + al);
if (al.contains(three)) {
System.out.println("al contains three");
System.out.println("three is at index " + al.indexOf(three));
}
al.add(0, new Integer(5));
System.out.println("The capacity of al is now " + al.size());
System.out.println("al now contains " + al);
al.remove(1);
System.out.println("The capacity of al is now " + al.size());
System.out.println("al now contains " + al);
al.set(0, three);
System.out.println("al now contains " + al);
}
} list.remove(value);
D:\java\util>javac TestArrayList.java
D:\java\util>java TestArrayList
The capacity of al is 5
al now contains [0, 1, 2, 3, 4]
al contains three
three is at index 3
The capacity of al is now 6
al now contains [5, 0, 1, 2, 3, 4]
The capacity of al is now 5
al now contains [5, 1, 2, 3, 4]
al now contains [3, 1, 2, 3, 4]
List ÀÎÅÍÆäÀ̽º¸¦ ±¸ÇöÇÑ Å¬·¡½ºµéÀ» ÅëÇÏ¿© List°´Ã¼¸¦ »ý¼ºÇÕ´Ï´Ù.
jabookÀúÀÚ¸íÇÔ |
Á¦¸ñ:¼Ò¼³°°Àº¹Ì´ÏÄÚµå ÀÛ¼ºÀÚ:Àںϸâ¹ö ±è¿Ï±â |