Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

arraylist methods in java

// Assign to list variable directly with STREAM FILTER METHID
ArrayList<String> filteredColors = (ArrayList<String>) colors.stream().filter(x -> x.contains("o")).collect(Collectors.toList());

// Clone and remove unwanted(TRADITIONAL FILTERING)
filteredColors = (ArrayList<String>) colors.clone();
filteredColors.removeIf(x -> !x.contains("o"));

// Find specific element
colors.stream().filter(x -> x.contains("ora")).findFirst().get();
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #arraylist #methods #java
ADD COMMENT
Topic
Name
9+3 =