-3

我不断收到预期的错误消息“)”。我无法确定原因。

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);


            }
        }
    }  
4

2 回答 2

4

if您需要在语句中有一个条件:

if(condition) {
}
于 2012-07-22T11:55:29.317 回答
1

整个状态有点乱。

我认为它应该是这样的:

if(selection.equals("L")) {
  cDraw.loadFloat(floatDrawer);
}
于 2012-07-22T12:04:33.443 回答