2014-09-29 97 views
-2

這是說我錯過了一個'}',我不知道在哪裏?我已經重新啓動eclipse,錯誤仍然存​​在...我有java的基礎知識,但沒有錯?語法錯誤'}'

if(args.length > 0) 
    { 
     print("Started with arguments:"); 
     for(int i=0; i < args.length;i++) 
     { 
      print(args[i]); 
     } 
     for(int y=0; y < args.length;i++) 
     { 
      if(args[y].startsWith("PATH=") == true); 
      { 
       setEXEPath(args[y].substring(5)); 
      } //<-- THIS line 
      else if(args[y].startsWith("DIRECTSTART=") == true) 
      { 
       if(args[y].substring(12).equals("true") == true) 
       { 
        enableWorking(); 
       } 
       else 
       { 
        disableWorking(); 
       } 
      } 
     } 
    } 
+5

檢查你的'''。 – 2014-09-29 16:09:14

+0

廢話,日食沒有提到這一行 – 2014-09-29 16:10:19

+1

這是一個很好的理由,在條件或循環的同一行上打開花括號。 – chrylis 2014-09-29 16:12:20

回答

0

這是你的問題:

if(args[y].startsWith("PATH=") == true); <-- remove the semi colon 
1

問題是if後分號(;):

if(args[y].startsWith("PATH=") == true); 

讓我們來看看java中如何解釋這一點:

// If some condition, do nothing - the ; terminates the if 
if(args[y].startsWith("PATH=") == true); 

// An anonymous block that's always called. 
// As noted above, the if have been terminated. 
{ 
    setEXEPath(args[y].substring(5)); 
} 

// An else if! 
// But this cannot be, as it does not follow an if's block! 
// Hence, this is a syntax error. 
else if(args[y].startsWith("DIRECTSTART=") == true)