Friday, March 4, 2011

How do I know the size of ArrayList?


/**---------------------------------------------------------*
* @author Madarapu Naveen *
* http://madarapunaveen.blogspot.com *
* ---------------------------------------------------------*
*/

import java.util.ArrayList;
import java.util.List;

public class ArrayListSize {
public static void main(String[] args) {
List list = new ArrayList();
list.add("Item 1");
list.add("Item 2");

int size = list.size();
System.out.println("size = " + size);
}
}


No comments:

Post a Comment