我收到此錯誤信息說標識符預計Java - 錯誤:<identifier>預計,如何解決它?
newIntArray3 = addValues(StackA.pop(), StackB.pop());
有人可以幫助我嗎?
我想用字符逐字符添加兩個數字,並使用彈出的堆棧顯示答案。
import java.util.*;
public class sandy {
public static void main(String[] args){
int[] newIntArray1 = new int[]{5,9,2};
int[] newIntArray2 = new int[]{4,7,5,6};
Stack StackA = new Stack();
Stack StackB = new Stack();
Stack StackC = new Stack();
StackA.push(newIntArray1[0]);
StackA.push(newIntArray1[1]);
StackA.push(newIntArray1[2]);
StackB.push(newIntArray1[0]);
StackB.push(newIntArray1[1]);
StackB.push(newIntArray1[2]);
StackB.push(newIntArray1[3]);
while (!StackA.empty() && !StackB.empty()) {
int[] newIntArray3 = new int[4];
@SuppressWarnings("unchecked")
newIntArray3 = addValues(StackA.pop(), StackB.pop());
int i=0;
while (i<=3);
StackC.push(newIntArray3);
i++;
}
System.out.println("result: " + StackC.pop() + StackC.pop() + StackC.pop() + StackC.pop());
}
public void addValues() {
int x , y = 0;
int addValues = 0;
addValues = x+y;
System.out.println(addValues);
}
}
'java的!= javascript' –
爲什麼標記爲'javascript'? – abhishekkannojia
'while(i <= 3);'我看到一個無限循環。請正確發佈您的代碼。 – abhishekkannojia