How to print statement outside loop to avoid duplicates?
I would like my print statement to be outside the loop so the statement
doesn't print the same thing over and over. The for loop below simply
checks a number from one array against another to find out how many
matches have been found. Defining the variables above and printing the
statements below results in a "variable not initialised error" which is
understandable.
for (int i = 0; i < 6; i++)
{
int chkNum = myArray[i];
int lottMtch = count(chkNum, rndNum);
if (lottMtch > 0)
{
System.out.println(lottMtch + "matches found");
System.out.print(chkNum);
}
else {
System.out.print("no matches found");
}
}
No comments:
Post a Comment