• Viernes 19 de Abril de 2024, 11:46

Autor Tema:  modificar datos del arreglo por ej un nombre  (Leído 2322 veces)

thinlizzy

  • Miembro activo
  • **
  • Mensajes: 27
    • Ver Perfil
modificar datos del arreglo por ej un nombre
« en: Viernes 19 de Abril de 2013, 03:35 »
0
que sentencia puedo utilizar para modificar un dato de un arreglo por ej Paul que pertenece a la matriz[1][2] cambiarlo por JOSE


public static void main(String[] args) {
        // TODO code application logic here
        // Creamos una matriz de 3x3
                String matriz[][]= new String[6][5];
                System.out.print("\t");
               
               
                // Inicializamos los valores de la matriz
                matriz[0][0] = "RUT|";
                matriz[0][1] = "NOMBRE  | ";
                matriz[0][2] = "APELLIDO|";
                matriz[0][3] = "2º APELLIDO| ";
                matriz[0][4] = "EDAD| ";
               
               
                matriz[1][0] = "1.111.111-1|";
                matriz[1][1] = "paul|";
                matriz[1][2] = "mccatrney  |";
                matriz[1][3] = "xxxxx     |";
                matriz[1][4] = "25   |";
               
               
                matriz[2][0] = "2.222.222-2|";
                matriz[2][1] = "Mario   |";
                matriz[2][2] = "Raul   |";
                matriz[2][3] = "Muñoz      |";
                matriz[2][4] = "24   |";
               
               
                matriz[3][0] = "3.333.333-3|";
                matriz[3][1] = "Jose    |";
                matriz[3][2] = "Albert |";
                matriz[3][3] = "Perez      |";
                matriz[3][4] = "23   |";
               
               
                matriz[4][0] = "4.444.444-4|";
                matriz[4][1] = "Miguel  |";
                matriz[4][2] = "Nuñez    |";
                matriz[4][3] = "Caceres    |";
                matriz[4][4] = "22   |";
               
               
                matriz[5][0]="5.555.555-5|";
                matriz[5][1] = "Roberto |";
                matriz[5][2] = "Mendez   |";
                matriz[5][3] = "Roa        |";
                matriz[5][4] = "21   |";
               
               
               
           
                // Recorremos la matriz
                for (int x=0; x < 6; x++) {
                        for (int y=0; y < 5; y++) {
                               
                            System.out.print (matriz
  • [y]+" ");

                           
                           
                           
   }
                        System.out.println ();
                        System.out.println("--------------------------------------------------");
                        System.out.print( " ");
                       
   
}
               
   
   
 }
}

arielb

  • Moderador
  • ******
  • Mensajes: 771
  • Nacionalidad: pa
    • Ver Perfil
    • http://coder-pa.blogspot.com
Re:modificar datos del arreglo por ej un nombre
« Respuesta #1 en: Viernes 19 de Abril de 2013, 17:57 »
0
Hola, en este caso de la misma forma que lo agregaste.
Es decir:
matriz[1][2] = "JOSE"
"Porque de tal manera amó Dios al mundo que dio a su hijo unigénito para que todo aquél que en él crea no se pierda mas tenga vida eterna"
Juan 3:16

http://coder-pa.blogspot.com

thinlizzy

  • Miembro activo
  • **
  • Mensajes: 27
    • Ver Perfil
Re:modificar datos del arreglo por ej un nombre
« Respuesta #2 en: Viernes 19 de Abril de 2013, 18:56 »
0
mmm la verdad no entendi muy bien tu explicacion