看板java
标 题有关for 回圈
发信站成电风之谷BBS (Thu Oct 26 08:11:56 2006)
转信站ptt!ctu-reader!Spring!news.nctu!news.nsysu!news.mksh.phc!news.ccns.nck
int a=1,b=10;
for(;a++<=3;b++)
{System.out.println("a="+a+"b="+b);}
其输出为
a=2b=10
a=3b=11
a=4b=12
请问为何会有a=4这种情况呢?
另一种..
int a=1,b=10;
for(;++a<=3;b++)
{System.out.println("a="+a+"b="+b);}
其输出为
a=2b=10
a=3b=11
此差异之成因...?
另..for的initial写在( )内和先宣告的差别是..?
小弟用for写nested loop时..initial写的位置不同.其输出结果也差异甚大.
--
□ Origin: 风 之 谷 bbs.ee.ncku.edu.tw □ From: 140.116.102.42