Java 如何重置到代码中的某个点
我只想在那里再做一次陈述,最后一次 显然是语法错误,应该删除。 这是一个语法错误吗?我错过什么了吗? 拜托,我是新手,不熟练。在Java中(a | | |(b | | | c))可以编写(a | | b | | | c),这避免了代码所遇到的括号问题 但如果让我猜。。。是这条线Java 如何重置到代码中的某个点,java,Java,我只想在那里再做一次陈述,最后一次 显然是语法错误,应该删除。 这是一个语法错误吗?我错过什么了吗? 拜托,我是新手,不熟练。在Java中(a | | |(b | | | c))可以编写(a | | b | | | c),这避免了代码所遇到的括号问题 但如果让我猜。。。是这条线 import java.util.Scanner; public class playerinput { private static final String = null; private st
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;
}
}
}
}
看起来末端多余的大括号是不必要的。正确缩进代码作为开始。如果
语句цццц),则一个有两个括号。){{
看起来有点像……仔细检查你的大括号。还有,为什么在你只使用条件OR运算符的情况下在if语句中使用这么多括号呢?Eclipse让我这样做的原因是括号太少了,并试图正确地跟随大括号之类的东西?
if (Response2.equals("Fine")||(Response2.equals("Yea")(Response2.equals("Yes")
||(Response2.equals("Sure")||(Response2.equals("I guess")
||(Response2.equals("I suppose"))))))){{