-2
我正在嘗試編寫代碼,它需要3個輸入值10 4 3.您可以看到kdx值爲0.當它調用函數hello時,qdx的值將更改爲11,但是它應該是0.並且返回值也是11.你知道它爲什麼會發生嗎?函數的返回值
import java.util.Scanner;
import java.io.FileNotFoundException;
public class test1 {
private static final int FORWARD = 1;
private static final int BACKWARDS = -1;
private static Scanner scn = new Scanner(System.in);
public static void main(String args[]) throws FileNotFoundException {
int N = scn.nextInt();
int k = scn.nextInt();
int m = scn.nextInt();
while (N != 0) {
boolean[] offQueue = new boolean[N];
int offCount = 0;
int kdx = 0;
int mdx = N - 1;
kdx = hello(k, offQueue, kdx, FORWARD);
System.out.println(kdx);
}
}
private static int hello(int q, boolean[] offQueue, int qdx, int direction) {
return qdx;//Problem is here
}
}
您可以使用IDE *中提供的*調試模式來檢查這些 –
http://ideone.com/vQQbBP我無法複製它.. –
您是否可能省略了'hello'的某些代碼? –