adspace


Which is better setter or constructor injection?

Answer Posted / Nikunj Kumar

Neither setter nor constructor injection is inherently better. The choice depends on the specific needs of the application and design preferences. Setter injection allows for easier configuration but can lead to looser coupling, while constructor injection promotes stronger coupling but enforces dependencies at object creation.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between @controller and @restcontroller in spring?

556


How can you inject java collection in spring?

518


What is lazy class?

490