Yahari
Posts: 2
Nickname: yahari
Registered: Jan, 2004
|
|
Re: Why it behaves differently?
|
Posted: Jan 30, 2004 1:06 AM
|
|
for convenience's sake,I give the result of the code as follows,
firstly,set i=0,compile,and part1 run,the result looks like this:
static: 3 non-static: 5
static: 4 non-static 6
static: 333 non-static: 5
static: 888 non-static 6
then,set i=1,compile,and part2 run,the result:
*******************
static: 0 non-static: 5
static: 4 non-static 6
secondly,comment out the if-else circle,join part1 and part2 into one,and run it,the result is like this:
static: 3 non-static: 5
static: 4 non-static 6
static: 333 non-static: 5
static: 888 non-static 6
*******************
static: 333 non-static: 5
static: 888 non-static 6
as you see,unlike running it twice,if running part1 and part 2 at one time,the static values preserved successfully.
|
|