Java Static Blocks, Variables and Methods

Static Member :-

What is a static member ? Static member is a member of a class that which is not interact or associate of  an instance of a class. This can be access without creating a object of a class. Moreover static members are being executed when class load in to the memory.  Further static members are accessible from any where and certain member is common for every instances. All objects use some instance of a static member.



Hash Map

HashMap is one of the most performing data structure in java collection framework. This provides constant time for both insertion and retrieval. This is used for large scale data since this is having high performance in insertion and retrieval. However this performance is depending on the two factors such as initial capacity and load factor. We can construct HashMap in four way and default constructor is having load factor is .75 and initial capacity as 16.


Singleton Design Pattern

This is the pattern which ensures there will be only one instance of a class in JVM and it can be accessed via globally. Generally this pattern is used to be on caching, logging, settings and configurations and so on.

Static class has below properties such as : –

  1. Static Member – this keeps the instance of class.
  2. Private constructor – this avoids creating multiple instances from this class.
  3. Static public method – the only one instance can be accessed via globally through this method.