支架预计。但是哪里?

时间:2012-07-22 11:52:37

标签: 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 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);


            }
        }
    }  

2 个答案:

答案 0 :(得分:4)

您需要在if声明中包含条件:

if(condition) {
}

答案 1 :(得分:1)

整个情况有点混乱。

我认为它应该是这样的:

if(selection.equals("L")) {
  cDraw.loadFloat(floatDrawer);
}