Working with Dynamic Arrays - Java Collection Framework

Java examples for Collection Framework:List

Introduction

Use an ArrayList.

Demo Code

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

public class Main {

  public static void main(String[] args) {

    List<String> stocks = new ArrayList<>();
    stocks.add("ORCL");
    stocks.add("AAPL");
    stocks.add("GOOG");
    stocks.add("IBM");
    stocks.add("MCD");
    System.out.println("stocks: " + stocks);

  }/* w ww  . jav a  2s . c  o  m*/
}

Result


Related Tutorials