一些Java关键字概念问题
请帮助我用简单的示例概念化以下关键字的含义:
- strictfp
- assert
- 瞬态
- 本机
- 同步
Please help me to conceptuallize meaning of following keywords with simple example :
- strictfp
- assert
- transient
- native
- synchronised
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您想要的所有回复都在 Java 语言规范 中:
All the replies you want are in the Java Language Specification :
看看谷歌一下会给你带来什么。问题是,你为什么不自己用谷歌(bing,yahoo)搜索它?
http://en.wikipedia.org/wiki/List_of_Java_keywords
虽然此页面不包含例如,每个定义都有一个指向更详细定义的链接,在某些情况下,还有包含示例的资源。
See what a little google will get you. Question is, why didn't you google (bing, yahoo) it yourself?
http://en.wikipedia.org/wiki/List_of_Java_keywords
Although this page doesn't contain examples, each definition has a link to a much more detailed definition, and in some cases, resources that contain examples.
strictfp
:浮点计算取决于处理器的架构。处理器中的数字表示格式会略有不同,这会影响浮点运算的误差范围。 Java 的早期版本在所有实现中强制采用通用表示,而不管底层 CPU(x86、PPC 等)如何。这意味着浮点运算必须被解释并且不能像处理器那样快地完成。后来的 Java 版本(如果我没记错的话,是 1.2)消除了这个限制,直接使用处理器来获得更快的结果,但代价是浮点结果依赖于 CPU 架构。具有scrictfp
的类或方法将强制结果独立于 CPU 架构。assert
:强制执行断言/“契约”。native
:用于 JNI(例如链接到 C 库)。transient
:用于(非)序列化。synchronized
:我只能推荐Java Concurrent in Practice。strictfp
: Floating point computation depends on the architecture of the processor. There will be slight differences in the number representation format in the processor, which will influence the error margin of the floating point operations. Early versions of Java were forcing a common representation in all implementations, irrespectively of the underlying CPU (x86, PPC, ...). This meant that the floating point operations had to be interpreted and couldn't be done as fast as the processor would have done. Later versions of Java (1.2 if I remember well) removed that constraint, to make direct use of the processor for faster result, at the expense of making the floating point results depend on the CPU architecture. Classes or method withscrictfp
will force the result to be independent of the CPU architecture.assert
: to enforce assertions/"contracts".native
: for JNI (linking to C libraries, for example).transient
: for (non) serialization.synchronized
: I can only recommend Java Concurrent in Practice.