我是 Java 新手并且正在学习 - 所以请原谅这可能是一个潜在的愚蠢问题!
这是一个简单的剪刀石头布游戏......
使用 BlueJ 我不断收到此错误;
“不兼容的类型”
运行此代码时;
import comp102.*;
import java.util.Scanner;
public class RPS{
String paper = "paper";
String rock = "rock";
String scissors = "scissors";
public void playRound(){
String paper = "paper";
String rock = "rock";
String scissors = "scissors";
System.out.print ('\f'); // clears screen
Scanner currentUserSelection = new Scanner(System.in);
String enterText = null;
System.out.println("Make your Selection; Paper, Rock or Scissors: ");
enterText = currentUserSelection.next();
System.out.println("enterText = " + enterText);
if(enterText = paper){
System.out.println("the IF Stmt is working");
}
}
错误是指这一行“if(enterText = paper){”
非常感谢