• Google+
  • Twitter
  • YouTube
  • RSS
  • Facebook

ArrayList: Java Collections Framework Video Tutorial, Part 1

The first part of a series on the Java Collections Framework, an absolutely vital set of classes for organising data in your code. In this part we’ll look at ArrayList; an expandable array. ArrayList is probably the most used and easiest to use member of the collections framework.

After starting the video, click the maximise button to make it fullscreen so you can see the code!

Code For This Tutorial


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

public class App {

	public static void main(String[] args) {
		ArrayList<Integer> numbers = new ArrayList<Integer>();

		// Adding

		// Retrieving

		System.out.println("nIteration #1: ");
		// Indexed for loop iteration
		for (int i = 0; i < numbers.size(); i++) {

		// Removing items (careful!)
		numbers.remove(numbers.size() - 1);

		// This is VERY slow

		System.out.println("nIteration #2: ");
		for (Integer value : numbers) {

		// List interface ...
		List<String> values = new ArrayList<String>();

Learn to program Java Swing with my complete video course – desktop programming and applets. Includes 7 free videos. Click here for details.