Simple Problem of programming

Well, I'm a student of Java. And I'm having problems with a coding... well... The thing is that I have to switch the values I gave to 2 "tables" (sorry, I don't know these terms in English xD), I mean, there are columns and rows... I will write my code here to a better understanding...

/**

* @(#)marrelos.java

*

* marrelos Applet application

*

* @author

* @version 1.00 2006/11/15

*/

import java.awt.*;

import java.applet.*;

publicclass marrelosextends Applet{

publicvoid init(){

}

//Paso 1

publicfinalint MAX=10;

//Paso 6 y 7

publicvoid paso6(int matriz[][]){

for(int i=0; i<MAX; i++)

for(int j=0; j><MAX; j++)

matriz[i][j] = 1;

}

//Paso 8

publicvoid diagonalPrincipal(int matriz[][]){

for(int i=0; i><matriz.length; i++)

for(int j=0; j><matriz[0].length; j++)

if(i==j){

matriz[i][j] = 2;

}

}

//Paso 9

publicvoid bajoDiagonalPrincipal(int matriz[][]){

for(int i=0; i><matriz.length; i++)

for(int j=0; j><matriz[0].length; j++)

if(i><j){

matriz[i][j] = 3;

}

}

//Paso 10

publicvoid sobreDiagonalPrincipal(int matriz[][]){

for(int i=0; i><matriz.length; i++)

for(int j=0; j><matriz[0].length; j++){

if(i>j){

matriz[i][j] = 4;}

}

}

//Paso 11 (this is the one I'm having problems with, it is supposed to change the values that are displayed on Paso 9 and 10)

publicvoid intercambia(int matriz[][]){

int aux = 0;

for(int i=0; i<matriz.length-1; i++){

for(int j=matriz[0].length-1; i!=j; j++){

aux = matriz[i][j];

matriz[i][j] = matriz[j][i];

matriz[j][i] = aux;

}

}

}

//Impresiones Matrices y Paso 12

publicvoid imprimir(int matriz[][], Graphics g){

int x=15;

int y=15;

for (int i=0; i><matriz.length; i++){

for (int j=0; j><matriz[0].length; j++){

g.drawString("" + matriz[i][j], x, y);

y=y+15;

}

y=15;

x=x+15;

}

}

publicvoid paint(Graphics g){

//Impresiones de Matrices

int matriz[][] =newint[MAX][MAX];

paso6(matriz);

diagonalPrincipal(matriz);

bajoDiagonalPrincipal(matriz);

sobreDiagonalPrincipal(matriz);

intercambia(matriz);

imprimir(matriz, g);

}

}

I hope someone can help me doing this ^^ it gets me a headache .-. I hope this is the right forum xD, I get confused with all those subforums.>

[5971 byte] By [Deus_Exa] at [2007-10-3 10:05:15]
# 1
Reposted.Reply here: http://forum.java.sun.com/thread.jspa?threadID=786718&messageID=4470592
pbrockway2a at 2007-7-15 5:24:30 > top of Java-index,Desktop,Developing for the Desktop...