Archive for January, 2010

What is a WeakHashMap?

A WeakHashMap interface extends AbstractMap and implements Map. It is a hashtable-based Map implementation with weak keys. An entry in a WeakHashMap will automatically be removed when its key is no longer in ordinary use. When a key has been discarded its entry is effectively removed from the map, so this class behaves somewhat differently than other Map implementations.

Both null values and the null key are supported. This class has performance characteristics similar to those of the HashMap class, and has the same efficiency parameters of initial capacity and load factor.

  • Share/Bookmark

What is the AnnotableElement interface?

The interface AnnotatedElement represents an annotated element of the program currently running in this VM. This interface allows annotations to be read reflectively. The annotations returned by methods in this interface are immutable and serializable. It is permissible for the caller to modify the arrays returned by accessors for array-valued enum members; it will have no affect on the arrays returned to other callers.

If an annotation returned by a method in this interface contains a class-valued member referring to a class that is not accessible in this VM, attempting to read the class by calling the relevant class-returning method on the returned annotation will result in a TypeNotPresentException.

  • Share/Bookmark

What is Writer?

Writer is an abstract class. It defines streaming character output. It is a character-oriented class and does not support primitive datatypes or objects. Writer class is used to write characters to output streams using the desired character encoding. It also writes Unicode characters to output streams.

  • Share/Bookmark

How to enable or disable an assertion?

An assertion can be enabled or disabled for a class or a package during runtime as follows:

-da ClassName or -da PackageName: This will disable the assertion for a class or a package respectively.

-ea ClassName or -ea PackageName: This will enable the assertion for a class or a package respectively.

  • Share/Bookmark