Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (3.5k points)

In a managed bean, @PostConstruct is called after the regular Java object constructor.

Why would I use @PostConstruct to initialize by bean, instead of the regular constructor itself?

1 Answer

0 votes
by (46k points)

  • because when the constructor is described, the bean is not hitherto initialized - i.e. no dependencies are included. In the @PostConstruct method, the bean is completely initialized and you can manage the provinces.
  • because this is the promise that ensures that this method will be requested only once in the bean lifecycle. It may occur (though unlikely) that a bean is instantiated complicated times by the container in its internal operation, but it ensures that @PostConstruct will be requested only once.

Related questions

Browse Categories

...