Re: [問題] 關於for回圈

看板java作者 (shooting star)時間19年前 (2006/06/02 20:48), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/8 (看更多)
※ 引述《CMJ0121 (請多指教!!)》之銘言: : public class test : { : public static void main(String[] args) : { : int i=0; : for(i=0; i<100; ++i) : if(i==3) : break; : for(i;i<100;++i) : System.out.println("test"); : } : } : 精簡版的CODE : 然後 : 為什麼第二的回圈 : 他給我的error說 : for(i;i<100;++i) : ^ : not a statement : 我在C++可以做的事情 : 再java就不能做了阿!? : 這跟java本身有關嗎!? 你第一個for迴圈結束後, i就被回收了 所以你第二個迴圈要用i的時候 compiler當然不知道 i 是啥囉 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.116.171.4
文章代碼(AID): #14W3EFDb (java)
討論串 (同標題文章)
文章代碼(AID): #14W3EFDb (java)