fork(1) download
  1. import java.util.Arrays;
  2. import java.util.stream.IntStream;
  3.  
  4. class Teste {
  5. public static void main(String[] args) {
  6. int[] numeros = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
  7. int[] quadrados = IntStream.of(numeros).map(x -> x * x).toArray();
  8. System.out.println(Arrays.toString(quadrados));
  9. }
  10. }
Success #stdin #stdout 0.19s 2841600KB
stdin
Standard input is empty
stdout
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]