如何重置到我的代码中的某个点

时间:2015-12-01 01:18:24

标签: java

import java.util.Scanner;

public class playerinput {

    private static final String  = null;
    private static Scanner user_input;

    public static void main(String[] args) {
        user_input = new Scanner (System.in);
        String firstName;
        System.out.print("Enter your name here:");
        firstName = user_input.next();
        String lastName;
        System.out.print("Ok cool, and your last?:");
        lastName = user_input.next();
        String thankYou;
        thankYou = "Alright," + ' ' + firstName + ' ' + lastName + ',' + ' '
         + "that's all we'll need. Have a nice day, and thank you again.";      
        System.out.println(thankYou);   
        System.out.println("Oh, one more question,");
        System.out.println("if you don't mind.");
        String Response = user_input.next();
        if (Response.equals("Yea?")||(Response.equals("Yes?")
                ||(Response.equals("Sure")))){
            System.out.println("How old are you, sir?");
        }
        else {
            System.out.println("That's not the answer");
            System.out.println("im looking for...");
            System.out.println("Please, reconsider.");
            String Response2 = user_input.next();
            if (Response2.equals("Fine")||(Response2.equals("Yea")||(Response2.equals("Yes")
                    ||(Response2.equals("Sure")||(Response2.equals("I guess")
                    ||(Response2.equals("I suppose"))))))){{
                System.out.println("Good, let us procede.");
                System.out.println("How old are you?");
                String Response3 = user_input.next();
            }
            else {
                System.out.println("Fine then, be that way.");
                break;
            }
        }   
    }
}

我只想在那里做另一个声明,最后一个 显然是一个语法错误,应删除。 这是一个语法错误怎么样?我错过了什么吗? 拜托,我是新人,不熟练。

1 个答案:

答案 0 :(得分:0)

可以编写Java中的

(a ||(b || c))(a || b || c),避免代码遭受的括号

但如果我猜测......这就是它。

     if (Response2.equals("Fine")||(Response2.equals("Yea")(Response2.equals("Yes")
                ||(Response2.equals("Sure")||(Response2.equals("I guess")
                ||(Response2.equals("I suppose"))))))){{

看起来不需要额外的花括号。