hehe.. some kind of sudoku.. :D
ok let me elaborate further..
e.g int[][] a= new int[3][3];
this would look like..
a[0][0] a[0][1] a[0][2]
a[1][0] a[1][1] a[1][2]
a[2][0] a[2][1] a[2][2]
I would like to compare these values and at the same time get the coordinates of the locations which have the same values..
From the illustration, if a[j] have values,,,
1 2 3
3 4 5
6 7 8
I should get the coordiantes 0,2 and 1,0..
PS
Im such a newbie to Java.. :D And any help from you guys who I think are prof would be appreciated so much by me.. TY.
Hi Kat..,
try this one,
public static void main(String[] args) {
int[][] a = new int[3][3];
a[0][0] = 1;
a[0][1] = 2;
a[0][2] = 3;
a[1][0] = 3;
a[1][1] = 4;
a[1][2] = 5;
a[2][0] = 6;
a[2][1] = 7;
a[2][2] = 8;
LinkedHashMap m = new LinkedHashMap();
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
if(m.containsKey(a[i][j])){
System.out.println("Duplicated indexes in coords: (" + i + "," + j + ")");
System.out.println("and (" + m.get(a[i][j]) + ")");
}else{
m.put(a[i][j], i + "," + j);
}
}
}
}
cheers,
mleiria