Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java filter list of dupllicate netries

public void 
  givenListContainsDuplicates_whenRemovingDuplicatesWithJava8_thenCorrect() {
    List<Integer> listWithDuplicates = Lists.newArrayList(5, 0, 3, 1, 2, 3, 0, 0);
    List<Integer> listWithoutDuplicates = listWithDuplicates.stream()
     .distinct()
     .collect(Collectors.toList());

    assertThat(listWithoutDuplicates, hasSize(5));
    assertThat(listWithoutDuplicates, containsInAnyOrder(5, 0, 3, 1, 2));
}
Comment

PREVIOUS NEXT
Code Example
Java :: short array in java 
Java :: They say that they have to create an instance to their application. What does it mean? 
Java :: h2-gramer-conf 
Java :: origin model color 
Java :: primefaces p:dataexporter encoding for pdf preProcessor 
Java :: java accept user input 
Java :: aws s3 client in java 
Java :: Recyclerview scramble after scrolling 
Java :: java.lang.ArrayIndexOutOfBoundsException: 4 
Java :: spring converter in initbinder 
Java :: what is abstract class 
Java :: run java in cmd 
Java :: object class java 
Java :: java 8 seconds to days 
Java :: method in java 
Java :: string split java 
Java :: multiple string java 
Java :: palindrome in java 
Java :: Search a 2D Matrix II 
Java :: import class from package java 
Java :: java transaction example 
Java :: why is java so verbose 
Java :: how to extract image from server url and store it in a folder in java 
Sql :: codeigniter print last sql query 
Sql :: postgres get columns names 
Sql :: forgot my mysql password mac 
Sql :: list all triggers in sql server 
Sql :: ci last query 
Sql :: sql server alter table column nullable 
Sql :: import sql file from laravel 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =