It is legal to have static block inside a class but illegal to have inside an interface. Please explain the reason.
Asked
Active
Viewed 155 times
1 Answers
-3
You can have static initialisation, but you cannot have a static block. The fact the static initialisation needs a static code block to implement does change the Java syntax.
The point is you are not meant to have code in an interface (before Java 8) but you are allowed to initialise fields.
.......

reza ganji
- 11
- 2