2012-07-22 104 views
-2

我不斷收到預期的錯誤消息「)」。我無法確定原因。括號預計。但是哪裏?

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


      } 
     } 
    } 
+1

(中左括號當我聽到「支架」我認爲[或。 – 2012-07-22 11:57:09

回答

4

你需要有一個條件在if聲明:

if(condition) { 
} 
1

整個情況是有點混亂。

我認爲它的意思是這樣的:

if(selection.equals("L")) { 
    cDraw.loadFloat(floatDrawer); 
} 
相關問題