Answers for "how to add items to an arraylist java"

1

adding items to an arraylist

import java.util.ArrayList;

public class Main {
  public static void main(String[] args) {
    ArrayList<String> cars = new ArrayList<String>();
    cars.add("Volvo");
    cars.add("BMW");
    cars.add("Ford");
    cars.add("Mazda");
    System.out.println(cars);
  }
}
Posted by: Guest on September-02-2021

Code answers related to "how to add items to an arraylist java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language