why can’t the method annotated in postconstruct be static?

Well, the name of the method already says what it does.

PostConstruct, this method will be called after the constructor. It can not be static because static methods can not access non static variables, methods and etc.

If you need something static to be run once, you can use static blocks.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top