2013-10-16 26 views
0

我似乎有問題與NetBeans的這段代碼,它似乎罰款從日食如果聲明沒有工作對於循環

for(int i = 0; i < shards.length();if 
      JSONObject obj = shards.getJSONObject(i); 
      try{ 
       page = http.GetPageContentUta(url1,ip); 
       http.platform = (String)userClubList.getJSONObject(0).get("platform"); 
       break; 

      }catch(Exception e){ 
       System.out.println("Exception"); 
      } 

     } 
+0

能否請你告訴這個代碼做什麼呢? –

+0

這個問題通常以相同的答案結束。分號是錯誤的,'for'後面不需要'if',只是括號。我非常懷疑Eclipse沒有抱怨這個代碼。 – Gamb

回答

3

請學習語法,for loop in Java到來。你寫的是錯誤的。 它看起來很好來自日食不,這沒關係,語法錯誤是Java語言不適用於任何IDE。

for(int i = 0; i < shards.length();if 

將其更改爲:

for(int i = 0; i < shards.length(); i++) { 
    //Remaining if and other codes 
} 
1

for循環定義你的時候你忘了一個括號。你也沒有說明如何增加我。

嘗試

for(int i = 0; i < shards.length(); i++) { 
    //code 
}