public class Main1
{
public static void main(String[] args)
{
printNumbers(7, 3);
}
public static int printNumbers(int numValue, int rows) {
for (int i = 0; i < rows; i++) {
int x = (int)(Math.random() * 10);
System.out.print(x);
if (numValue == x && i < rows) {
System.out.println(" ");
} else if (i < rows) {
System.out.print(x);
}
}
return printNumbers(7, 3);
}
}
It's supposed to print random numbers until you reach the numValue, then it creates a new row, and there is a specified amount of rows. Although I put 3 rows, this code keeps running infinite rows. I must be missing something. I'm new to making methods and this is my first crack at it all by myself.