My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.lineadecodigo.java.basico.arrays;

/**
* @file CrearMatriz.java
* @version 1.0
* @author Linea de Codigo (http://lineadecodigo.com)
* @date 08.julio.2010
* @url http://lineadecodigo.com/java/crear-una-matriz-en-java/
* @description Programa que nos permite crear una matriz con Java
*/

public class CrearMatriz {

public static void main(String[] args) {

// Creamos una matriz de 3x3
int matriz[][] = new int[3][3];

// Inicializamos los valores de la matriz
matriz[0][0] = 2;
matriz[0][1] = 4;
matriz[0][2] = 4;
matriz[1][0] = 6;
matriz[1][1] = 6;
matriz[1][2] = 9;
matriz[2][0] = 8;
matriz[2][1] = 10;
matriz[2][2] = 12;

// Recorremos la matriz
for (int x=0; x < matriz.length; x++) {
for (int y=0; y < matriz[x].length; y++) {
System.out.println (matriz[x][y]);
}
}



}

}

Change log

r261 by vcuervo on Jul 8, 2010   Diff
Crear una matriz con Java
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 897 bytes, 41 lines
Powered by Google Project Hosting