2014-09-29 95 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)