Hi, everybody. I've made a code of a "for" loop. Once i exceeds 4, the loop must stop. The input is in a JTextField. The problem is that the loop never stops although it exceeds 4. Can anybody help me?
The problem is here :
public void compare(int x)
{
for(int i=0;i<5;i++)
{
int n=Integer.parseInt(t.getText());
if(n==x)
{
l2.setText("Astonishing ! The number is really "+n);
t.setEditable(false);
break;
}
else if(n>x)
{
l2.setText("Move towards less values");
continue;
}
else if(n<x)
{
l2.setText("Move larger");
continue;
}
}
t.setText(null);
}
For more details please contact me through the site. Thanks a lot.