Advertisement
LightProgrammer000

Matriz [Bidimensional]

Jan 3rd, 2019
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. package Aulas_Console;
  2.  
  3. public class BA_Programa_13
  4. {
  5.     public static void main( String args [] )
  6.     {
  7.         // ATRIBUTOS
  8.        
  9.         /*             COLUNA[0]   COLUNA[1]      COLUNA[2]
  10.         LINHA [0] -    JOSÉ        91234-1234     professorjoseassis@gmail.com
  11.         LINHA [1] -    Bill        2222-2222      bill@outlook.com
  12.         LINHA [2] -    Linus       9999-9999      tux@linux.com
  13.         */
  14.         String [][] agenda = new String [][] { { "José", "91234-1234", "professorjoseassis@gmail.com"},
  15.                                                { "Bill", "2222-2222", "bill@outlook.com" },
  16.                                                 { "Linus", "9999-9999", "tux@linux.com" } } ;                          
  17.        
  18.         // Percorre linhas
  19.         for ( int i = 0; i < agenda.length ; i ++ )
  20.         {
  21.             System.out.println("-------------------");
  22.            
  23.             // Percorre colunas
  24.             for ( int j = 0; j < agenda.length ; j ++ )
  25.             {
  26.                 System.out.println( agenda [i][j] );
  27.             }
  28.         }
  29.        
  30.         System.out.println("===============================" + " \n" + "===============================");
  31.        
  32.         // Percorre todas as linhas e expõe todos os resultados linha a linha
  33.         for ( String [] agenda1 : agenda)
  34.         {
  35.             System.out.println("-------------------");
  36.            
  37.             for ( int j = 0; j < agenda.length; j++ )
  38.             {
  39.                 System.out.println( agenda1[j] );
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement