fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. import java.util.stream.* ;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. List < String > inputs = List.of( "red" , "yellow" , "green" , "yellow" , "blue" , "green" , "purple" );
  15. List < String > expected = List.of( "red" , "yellow" , "green" , "blue" , "purple" );
  16.  
  17. List<String> result =
  18. inputs
  19. .stream()
  20. .distinct()
  21. .collect(
  22. Collectors.toList()
  23. )
  24. ;
  25. boolean success = result.equals( expected );
  26.  
  27. System.out.println( "success = " + success );
  28. System.out.println( "result = " + result );
  29. }
  30. }
Success #stdin #stdout 0.12s 36536KB
stdin
Standard input is empty
stdout
success = true
result = [red, yellow, green, blue, purple]