Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- /**
- * Archivo Ejemplo.java Ejecuta : javac Ejemplo.java && java Ejemplo
- *
- * @author Atheyus
- *
- */
- public class Ejemplo {
- public static void main(String[] args) {
- String[][] matrizS = new String[2][2];
- matrizS[0][0] = "Palabra uno fila 1";
- matrizS[0][1] = "Palabra dos fila 1";
- matrizS[1][0] = "Palabra uno fila 2";
- matrizS[1][1] = "Palabra dos fila 2";
- Integer [] ejem = new Integer[5];
- ejem[0] = 112;
- ejem[1] = 132;
- ejem[2] = 13;
- ejem[3] = 111;
- ejem[4] = 13;
- recorre(ejem); // Vemos el primer orden
- Arrays.sort(ejem); // Cambiamos el orden
- recorre(matrizS);
- recorre(ejem); // Vemos el nuevo orden
- System.out.println(Arrays.toString(matrizS));
- }
- private static void recorre(Integer [] x) {
- for (int i = 0;i< (x.length);i++ ){
- System.out.println("Numero "+i+" : "+x[i]);
- }
- System.out.println("Ultimo valor : "+x[x.length-1]); // Para obtener el ultimo valor se usa esta solucion
- }
- private static void recorre(String[][] x) {
- for (int i = 0; i < x.length; i++) {
- int columnas = x[i].length;
- System.out.println("Fila : "+(i+1));
- for (int o = 0; o < columnas; o++) {
- System.out.println("Valor : "+x[i][o]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement