Some Java Keyword Concept Problem

Please help me to conceptuallize meaning of following keywords with simple example :

  • strictfp
  • assert
  • transient
  • native
  • synchronised

Answers


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.


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.


Need Your Help

Nhibernate mapping at run time

nhibernate fluent-nhibernate nhibernate-mapping

I am developing a site in which nhibernate is using. that is working fine for static mapping. but problem that i apply this application on existing database. so is there any way that mapping of cla...

How to prevent / handle ErrBadConn with Azure SQL Database

sql-server azure go azure-sql-database

I'm using this driver: https://github.com/denisenkom/go-mssqldb and on production with an Azure SQL Database Standard S3 level we are getting way too much ErrBadconn - driver: Bad connection return...