Las matrices en Java son objetos. Siempre se pasan por referencia. Entonces algo como (a pesar de su naturaleza fea y hacky):
import java.util.Arrays;
import java.util.stream.Collectors;
clase pública principal {
nulo a1 (Integer [] theIntegers) {
System.out.println (Arrays.stream (theIntegers).
mapa (i -> i * i).
mapa (Objeto :: toString).
collect (Collectors.joining (“,”)));
}
- Cómo obtener el valor más cercano al número al agregar elementos de matriz
- ¿Qué representan realmente los números de Grundy en un juego?
- ¿Cuál es el inverso matemático de 2 ^ N?
- ¿Existe tal cosa como un 'Algoritmo Maestro'?
- ¿Puedo obtener una breve descripción general del documento 'Generación precisa de hologramas utilizando el método basado en capas y el algoritmo de transformación de Fourier iterativo'?
nulo a2 (Entero [] [] theIntegers) {
System.out.println (Arrays.stream (theIntegers).
flatMap (Arrays :: stream).
mapa (i -> i * i * i).
mapa (Objeto :: toString).
collect (Collectors.joining (“,”)));
}
nulo a3 (Entero [] [] [] theIntegers) {
System.out.println (Arrays.stream (theIntegers).
flatMap (Arrays :: stream).
flatMap (Arrays :: stream).
mapa (i -> i * i * i * i).
mapa (Objeto :: toString).
collect (Collectors.joining (“,”)));
}
public static void main (String [] args) {
Main m = new Main ();
Entero [] [] [] ints = {
{{1, 2, 3}, {4, 5, 6}, {7}, {8, 9}},
{{10, 20, 30}, {40, 50, 60}, {70}, {80, 90}},
};
m.a1 (ints [0] [0]);
m.a2 (ints [0]);
m.a3 (ints);
}
}