Hello,
I'm trying to compare if two pictures are the same. This is the code I have for comparing. tamponIndice is declared as a global variable. I keep getting the value of zero. How can I change it to be the previous index ?

Thanks in advance.
public void actionPerformed(ActionEvent e) {
Object src = e.getSource();
int tamponImage = 0;
int temp = 0;


for (int i = 0; i < jbtnTout.length; i++) {
if (src == jbtnTout[i]) {
click++;

if (click == 1) {

jbtnTout[i].setIcon(icon[tableauChoisi[i]]);
temp = i;
tamponImage = tableauChoisi[i];

tamponIndice = i;
}

if (click == 2) {
click = 0;

if (tableauChoisi[tamponImage] == tableauChoisi[tamponIndice]) {

jbtnTout[i].setIcon(icon[tableauChoisi[i]]);
jbtnTout[temp].setIcon(icon[tableauChoisi[temp]]);


} else if (tableauChoisi[i] != tableauChoisi[tamponIndice]) {
jbtnTout[i].setIcon(icon[0]);
jbtnTout[tamponIndice].setIcon(icon[0]);

}
}
}
}
}