fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int matriz[][];
  13.  
  14. Scanner entrada = new Scanner(System.in);
  15. int linha=0, coluna =0;
  16.  
  17. System.out.println("Informe a quantidade de linhas da matriz");
  18. linha = entrada.nextInt();
  19.  
  20. System.out.println("Informe a quantidade de colunas da matriz");
  21. coluna = entrada.nextInt();
  22.  
  23. matriz = new int[linha][coluna];
  24.  
  25. for(int x=0; x < linha; x++){
  26. for(int y=0; y < coluna; y++){
  27. System.out.println("matriz ["+x+"]["+y+"] =");
  28. matriz[x][y]= entrada.nextInt();
  29. }
  30. }
  31.  
  32. for(int x=0; x < linha; x++){
  33.  
  34. for(int y=0; y < coluna; y++){
  35. System.out.print(matriz[x][y]+"\t");
  36. }//fim for
  37. System.out.println();//apenas para quebrar linha
  38. }//fim for
  39.  
  40. }
  41. }
Success #stdin #stdout 0.14s 321280KB
stdin
3
3
1
2
3
4
5
6
7
8
9
stdout
Informe a quantidade de linhas da matriz
Informe a quantidade de colunas da matriz
matriz [0][0] =
matriz [0][1] =
matriz [0][2] =
matriz [1][0] =
matriz [1][1] =
matriz [1][2] =
matriz [2][0] =
matriz [2][1] =
matriz [2][2] =
1	2	3	
4	5	6	
7	8	9