arraylist methods examples in java
Example 1: arraylist methods in java
ArrayList<String> filteredColors = (ArrayList<String>) colors.stream().filter(x -> x.contains("o")).collect(Collectors.toList());
filteredColors = (ArrayList<String>) colors.clone();
filteredColors.removeIf(x -> !x.contains("o"));
colors.stream().filter(x -> x.contains("ora")).findFirst().get();
Example 2: arraylist java methds
import java.util.ArrayList;
ArrayList<Integer> myList = new ArrayList<Integer>();
myList.add(0);
myList.remove(0);
myList.size();
myList.get(0);