问题和练习的答案:数字

Questions

答案: toHexString

答案: valueOf。这是如何做:

String base5String = "230";
int result = Integer.valueOf(base5String, 5);

答案: isNaN

Integer.valueOf(1).equals(Long.valueOf(1))

答案: 错误。这两个对象(IntegerLong)具有不同的类型。

Exercises

答案: 参见MinVariablesDemo。这是输出:

The smallest byte value is -128
The smallest short value is -32768
The smallest integer value is -2147483648
The smallest long value is -9223372036854775808
The smallest float value is 1.4E-45
The smallest double value is 4.9E-324
java Adder 1 3 2 10

该程序应显示16,然后退出。如果用户仅 Importing 一个参数,则程序应显示一条错误消息。您可以将程序基于ValueOfDemo

答案: 参见Adder

例如,假设您 Importing 以下内容:

java FPAdder 1 1e2 3.0 4.754

该程序将显示108.75。根据您的语言环境,小数点可能是逗号(,)而不是句点(.)。

答案: 参见FPAdder

首页