Topic: 一个小问题

  Print this page

1.一个小问题 Copy to clipboard
Posted by: lymhappy123
Posted on: 2008-12-24 16:41

public static void main(String[] args) {
int i = 0;
i = i++;
System.out.print(i);
}
为什么输出0?

2.Re:一个小问题 [Re: lymhappy123] Copy to clipboard
Posted by: JiafanZhou
Posted on: 2008-12-26 23:31

i++ will make the variable i change its value after the statement, hence i=i++ will have no effect on i at all.

As a solution, you should simply use i= ++i; or simply i++

Jiafan

3.Re:一个小问题 [Re: lymhappy123] Copy to clipboard
Posted by: lymhappy123
Posted on: 2008-12-29 13:44

谢谢 不过是英文回答,中文更好点


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923