First let’s know about what is Dependency Injection and why we need this.
Dependency injection is a software design pattern that implements inversion of control for resolving dependencies. A dependency is an object that can be used (a service). An injection is the passing of a dependency to a dependent object (a client) that would use it. DI is widely adopted because this technique helps developer for achieving loose coupling between objects and its collaborators, or dependencies. Rather than directly instantiating collaborators, or using static references, the objects a class needs in order to perform its actions are provided to the class in some fashion. Mostly there are three common approach to achieve DI Setter, Interface, and Constructor. [Wikipedia]