所以我有一個作業問題。這是我需要做的:需要編寫某種方法
Write the definition of a method , oddsMatchEvens , whose two parameters are arrays of integers of equal size. The size of each array is an even number. The method returns true if and only if the even-indexed elements of the first array equal the odd-indexed elements of the second, in sequence. That is if w is the first array and q the second array , w[0] equals q[1], and w[2] equals q[3], and so on.
我所擁有的是:
public boolean oddsMatchEvens(int[] w, int[] q){
int count = 0;
for(int i=0; i < w.length; i++){
if(w[i].equals(q[i + 1])){
count++;
if(count == w.length){
return true;
}
}
}
我收到此錯誤:
⇒ You almost certainly should be using: &&
⇒ You almost certainly should be using: +=
⇒ You almost certainly should be using: >=
這個名單讓我擔心,但應該讓他開始,他幾乎在那裏我敢肯定。 –
if(w [i] == q [i + 1])給我同樣的錯誤 – DaViDa
奇怪的作品對我來說很好。 –