类型检查

Ø 静态检查:类型types

    动态检查:值values

Ø Java和许多其他编程语言中的一个点是 它的原始数值类型有特例, 表现得不像我们习惯的整数和实数。因此,应该动态检查一些错误 根本不检查。


– Integer division: 5/2 does not return a fraction, it returns a truncated

integer.

– Integer overflow. If the computation result is too positive or too negative

to fit in that finite range, it quietly overflows and returns a wrong answer.

(no static / dynamic checking!) e.g., int big = 200000*200000;

– Special values in floating-point types. NaN (“Not a Number”),

POSITIVE_INFINITY, and NEGATIVE_INFINITY. e.g., double a=7/0;

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容