Do we have static constructor in java?

(Last Updated On: June 6, 2016)

Answer: No, we don’t have static constructor in java. Actually, java static constructor concept is not there. When we make a class constructor static, compiler will flash an error i.e.

“Illegal modifier for the constructor in type MyClass; only public, protected & private are permitted”.

In below example, at the compile time itself compiler will throw an error.

Note: Instead of static constructor we can use static block in java