不好意思,还想问学长几个问题
登录 | 论坛导航 -> 华新鲜事 -> 社会百科 | 本帖共有 7 楼,当前显示第 5 楼 : 从楼主开始阅读 : 本帖树形列表 : 返回上一页
作者:想念老乡 (等级:2 - 初出茅庐,发帖:160) 发表:2003-08-27 23:16:34  5楼  评分: 
come in
1。what is i after the following for loop?
for (int i=0;i<10;++i){
y+=i;
}
为什莫答案是undefined?不应该是10吗?

>> i is only defined within the for loop structure

2。analyze the following fragment:
double sum=0;
double d=0;
while(d!=10.0){
d+=0.1;
sum+=sum+d;
}
答案:the program may not stop because of the phenomenon referred t as numerical inaccuracy for uperating with floating-pointing numbers.
为啥?不懂~~~~

>> floating number is represented in IEEE 754 standards, it means that for any number of float type in java, the system keeps only the first 23 bit after decimal point and thus there is some error in magnitude....just search on google use IEEE 754 to find out more details

3。analyze the following code:
boolean even=false;
if(even=true){
system.out.println(" it is even!");
}
写得有错吗?结果是什莫?

>>true is first assign to variable even, and then the value of variable even is evaluated (it's true by now).
>> = is not equivalent to == , the first one is assignment and the second is comparison....


4。even=number%2==0
有这种写法么? 是什莫意思呢?计算机看到这个expression后又是怎样工作的?

>> number % 2 == 0 is first evaluated, it may be true or false and this boolean value is then assigned to variable even. for additional knowledge check out "java operator precedence"
Put your OWN COOL signature here!
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表

本帖共有 7 楼,当前显示第 5 楼,本文还有 N-1 层楼,要不你试试看:点击此处阅读更多 >>



请登录后回复:帐号   密码