Java 括号内为预期值。但是在哪里呢?
我一直收到错误消息“)”预期。我不知道为什么Java 括号内为预期值。但是在哪里呢?,java,Java,我一直收到错误消息“)”预期。我不知道为什么 import java.util.Scanner; public class PartA extends ChangeDrawer { public static void main (String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter P to mak
import java.util.Scanner;
public class PartA extends ChangeDrawer
{
public static void main (String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Enter P to make a purchase & receive your change");
System.out.println("Enter L to load the Change drawer");
System.out.println("Enter H to write the contents of the Change Drawer to a
web Page");
System.out.println("Enter E to exit the program"); //this is the user prompt
String selection = input.nextLine();
if{ //Error message: "(" expected
(String selection=L)
cDraw.loadFloat(floatDrawer);
}
}
}
在
if
语句中需要有一个条件:
if(condition) {
}
整个情况有点混乱 我想应该是这样的:
if(selection.equals("L")) {
cDraw.loadFloat(floatDrawer);
}
(是左括号。当我听到“括号”时,我想[或{。