gpt4 book ai didi

parsing - 解析编译错误时到达文件末尾

转载 作者:行者123 更新时间:2023-12-02 10:51:33 25 4
gpt4 key购买 nike

我是Java编程初学者。我该怎么做才能得到错误:解析时到达文件末尾

import java.util.Scanner;
class eng{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
String value;
String direct = "answer true or false to the following statement.";
String ques = "Twelve is greater than seven";
System.out.println(direct);
System.out.println(ques);
value = input.nextLine();
if ((value = "true")) {
System.out.println("you are correct");
} else {
System.out.println("you are wrong my friend");
}
}

最佳答案

  • 在代码末尾添加另一个“}”,您错过了一个

  • 2.您的代码中还有另一个错误
    if((value = "true"))

    这不是检查字符串是否相等的正确方法,应该有语法错误
    if(value.equals("true"))

    关于parsing - 解析编译错误时到达文件末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33249647/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com