标题:麻烦帮我解释一下
取消只看楼主
pine
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2004-8-10
 问题点数:0 回复次数:0 
麻烦帮我解释一下

what will happen when you attempt to compile and run the following code?

(assume that the code is compiled and run with assertions enabled)

public class AssertTest

{

public static void main(String args[])

{

float f1 = Float.NaN;

float f2 = f1;

float f3 = 1.2f;

try

{

assert(f2 == f1):f2= 2;

f3 = 1.5f;

}catch(AssertionError ae)

{

f3++;

}

f3 += f2;

System.out.println("f3 = " + f3);

}

}

A. compilation error at line 5

B.compilation error at line 7

C.It will print- f3 = 3.5

D.It will print- f3 = 4.2

E.It will print- f3 = NaN

在上面的assert(f2 == f1) : f2 = 2;中间的:不明白是什么意思。怎么解释这句话?还有NaN是什么意思?在做题碰到好多这样的题,好郁闷。。。。。麻烦高手帮帮忙解释一下,谢谢

搜索更多相关主题的帖子: 麻烦 解释 
2004-08-28 18:59



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-4669-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.286330 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved