fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.stream.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. List<Integer> numbers = Arrays.asList(3, 2, 2, 3, 7, 3, 5);
  14.  
  15. //get list of unique squares
  16. List<Integer> squaresList = numbers.stream().map( i -> i*i).collect(Collectors.toList());
  17.  
  18.  
  19. squaresList.forEach(ne -> {
  20. System.out.println("ne: " + ne);
  21. });
  22.  
  23. }
  24. }
Success #stdin #stdout 0.1s 52592KB
stdin
Standard input is empty
stdout
ne: 9
ne: 4
ne: 4
ne: 9
ne: 49
ne: 9
ne: 25