我不確定爲什麼我的if else語句在這個程序中不起作用。If-else語句錯誤'else'without'if'
int roll = (int) (Math.random()*7 + 1);
System.out.println("Rolled: " + roll);
System.out.println("Enter 'r' to roll again or 'h' to hold");
String answer = scan.next();
String answer1 = answer.toUpperCase();
if (answer1=="R"){
int roll2 = (int) (Math.random()*7 + 1);
System.out.println("Rolled: " + roll2);
else {
System.out.println("Your score = " + roll);
}
Watttch youse bracketsess ... –
@MartinJames我從來沒有見過咕嚕之前回答編程問題...哈哈 – zerobandwidth