Some Java Keyword Concept Problem
Please help me to conceptuallize meaning of following keywords with simple example :
See what a little google will get you. Question is, why didn't you google (bing, yahoo) it yourself?
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.
All the replies you want are in the Java Language Specification :
- strictfp (for classes, interfaces, methods) allows some specific coercion on algbraic operations
- assert useful to write test statements in code, unfortunatly voided by Sun spec (and the need to enable it during both compilation and execution)
- transient dirk is right, and I was wrong. transient relates to member fields that are not serialized.
- native allows the call of so-called native code i.e. code compiled for platform (C compiled with the correct compiler args)
- synchronized (which can be applied to both blocks and methods for always curious results)
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 with scrictfp 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.