List of usage examples for java.util ArrayList ArrayList
public ArrayList()
From source file:Main.java
public static void main(String[] args) { ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("1"); arrayList.add("2"); arrayList.add("3"); arrayList.set(1, "REPLACED ELEMENT"); for (String str : arrayList) { System.out.println(str);// w w w . ja v a 2s . c om } }
From source file:Test.java
public static void main(String[] args) { List arrayList = new ArrayList<>(); //List<String> arrayList = new ArrayList<>(); arrayList.add("First"); arrayList.add("Second"); }
From source file:Main.java
public static void main(String[] argv) { List<Number> numlist = new ArrayList<Number>(); numlist.add(new Integer(123)); numlist.add(new Float(123)); }
From source file:Main.java
public static void main(String[] args) { List<String> size = new ArrayList<String>(); size = deleteAll(size, "value"); }
From source file:Main.java
public static void main(String[] args) { ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("1"); arrayList.add("2"); arrayList.add("3"); System.out.println(arrayList.size()); arrayList.clear();/*w ww .jav a 2 s.c o m*/ System.out.println(arrayList.size()); }
From source file:Main.java
public static void main(String[] argv) { List<String> mascots = new ArrayList<>(); mascots.add("duke"); mascots.add("juggy"); String actual = mascots.stream().reduce((t, u) -> t + "," + u).get(); System.out.println(actual);/*from w ww. jav a 2 s . co m*/ }
From source file:Main.java
public static void main(String[] args) { List<Integer> l = new ArrayList<Integer>(); l.add(3);//www . j a v a 2 s. c o m l.add(2); l.add(1); l.add(4); l.removeIf(i -> { return i >= 3;//No return statement will break compilation }); System.out.println(l); }
From source file:Main.java
public static void main(String[] args) { ArrayList<String> list = new ArrayList<>(); list.add("A"); list.add("B"); list.add("C"); list.add("D"); list.add("E"); list.add("F"); list.add("G"); list.add("H"); System.out.println(list);//from ww w. j ava 2 s .c o m while (!list.isEmpty()) { long index = Math.round(Math.floor(Math.random() * list.size())); System.out.println("Name " + list.get((int) index)); list.remove((int) index); } }
From source file:Main.java
public static void main(String args[]) { ArrayList<Integer> arrlist = new ArrayList<Integer>(); arrlist.add(1);//from w w w . ja v a 2 s. c o m arrlist.add(2); arrlist.add(3); arrlist.add(4); arrlist.add(5); ArrayList<Integer> arrlist2 = new ArrayList<Integer>(); arrlist2.add(1); arrlist2.add(2); arrlist2.add(3); arrlist.removeAll(arrlist2); System.out.println(arrlist); }
From source file:Main.java
public static void main(String args[]) { ArrayList<Integer> arrlist = new ArrayList<Integer>(); arrlist.add(1);//from w w w . java 2 s . c o m arrlist.add(2); arrlist.add(3); arrlist.add(4); arrlist.add(5); ArrayList<Integer> arrlist2 = new ArrayList<Integer>(); arrlist2.add(1); arrlist2.add(2); arrlist2.add(3); arrlist.retainAll(arrlist2); System.out.println(arrlist); }