import java.io.*;
public class AdamHmwk4 {
public static void main(String [] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int counter1;
int counter2;
int counter3;
String answer = "";
System.out.println("Welcome to Adam's skip-counting program!");
System.out.println("Please input the number you would like to skip count by.");
counter1 = Integer.parseInt(br.readLine());
System.out.println("Please input the number you would like to start at.");
counter2 = Integer.parseInt(br.readLine());
System.out.println("Please input the number you would like to stop at.");
counter3 = Integer.parseInt(br.readLine());
System.out.println("This is skip counting by" + counter1 + ", starting at" + counter2 + "and ending at" + counter3 +":");
while (counter2 = counter3) {
counter2 = counter2 + counter1;
counter3 = counter2 + counter1;
}
}
}
我正在嘗試跳過計數程序。當我編譯此代碼時,行while(counter2 = counter3){
顯示爲不兼容類型錯誤。編譯器說它找到了一個「int」,但它需要一個「布爾」。請記住,我是一個新手,所以我還沒有在我的Java類中學過布爾值。Java:不兼容類型(int /布爾值)
如何讓while循環進入正確的循環?在應用Mik378的修復之後,環路不會激活。 –
如果在'while'行放置斷點,'counter2'和'counter3'的當前值是多少? – Mik378