weixin_47062643
weixin_47062643
2021-01-25 20:15

为啥我的if语句直接跳过了

  • java
public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String a;
        boolean flag = true;
        System.out.println("请确认选择 1(确定) or 2(取消)");
        a = scanner.next();
        if (a == "确定"){
            flag = false;
        }
        System.out.println(flag);
    }
}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

5条回答