0
嗨,我試圖讓這個通過我的代碼RELOOP之後,但它似乎只是退出它打印後的框中輸入:重新運行我的主要方法我boxPrint方法
import java.util.Scanner;
public class BoxPrint1 {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);// create scanner object called input
// delcare variables
int column;
int row;
System.out.printf("%nThis program prints a box"); // prompt user for input
System.out.printf("%n Please enter # of columns (< 1 to exit):");
column = input.nextInt();
System.out.printf("%n Please enter # of rows (< 1 to exit):");
row = input.nextInt();
boxPrint(column, row);
while(column > 0 && row > 0);
{ // calls boxPrint method and passes two arguments
// prompt user for input
System.out.printf("%n Please enter # of columns (< 1 to exit):");
column = input.nextInt();
System.out.printf("%n Please enter # of rows (< 1 to exit):");
row = input.nextInt();
}
}// end main
public static void boxPrint(int column, int row)
{
//insert nested for loops below
for(int i = 0; i < row; i++)
{
for(int j = 0; j < column; j++)
{
// prints * j times in a row
System.out.printf("*");
}
System.out.println();
} // end boxPrint method
}
// end class BoxPrint1
}
這是我的代碼,通常我得到輸出(它應該輸出)
等等,但它不會回到我的主要方法,並再次要求輸入?
在main方法開始時使用while(true)並在// end main之前關閉它。 – user6657161