I am fairly new to Java and every time I try to compare input to temp, I get all of the results in my array, even if input and temp are not the same.
Code:
if (jRadioButton1.isSelected())
{
String temp;
try
{
for (int i = 0; i < 500; i++)
{
temp = Integer.toString(Read.tempHigh[i]);
if ( input.equals(temp) );
{
j.TextArea3.append(temp);
j.TextArea3.append(input);
}
}
}
catch (NumberFormatException e)
{
jTextArea3.append("Please enter a number");
}
}
Your line…
Should not have the
;at the end of it. The;symbol is closing the if-statement off, so it will always run thej.TextArea3.append()lines no matter what the values ofinputandtempare.Your code above should therefore look like this…