我会将所有代码都放在一个大循环中吗?如果是这样,我该怎么做?我读到我可以将开头标记为循环并使用底部的继续关键字? 也可以有人告诉我为什么当我运行代码并输入2个整数(即3和9)并且除数为3时它返回:33456678
package loop;
import java.util.*;
public class MinilabLoopLogic
{
public static void main(String[ ] args)
{
int number1;
int number2;
int divisor;
Scanner kb = new Scanner(System.in); //you do it!
System.out.print("Please enter 2 integers (separated by spaces): ");
number1 = kb.nextInt();
number2 = kb.nextInt();
if (number1 < number2) {
System.out.println("\n\nThis program will generate numbers BETWEEN "
+ number1 + " " + number2);
}
else {
System.out.println("\n\nThis program will generate numbers BETWEEN "
+ number2 + " " + number1);
}
System.out.print("\nPlease enter the integer your output should be divisible by: ");
divisor = kb.nextInt();
if (number1 < number2){
for (int i = number1 + 1; i < number2; i++ ){
System.out.print(i);
if (i % divisor == 0){
System.out.print(i);
}
else
}
}