Dependency Injection a big name for a very simple concept. Objects interact with other objects. A piece of data or an object that an object requires is its dependency. Objects can fetch dependencies on their own as in the following example:

public MyClass() {
  myObj = Factory.getObj();
}

However, we can also provide the dependencies to the object so that it doesn’t have to fetch them as follows:

public MyClass (YourClass yourObj) {
  this.myObj = yourObj;
}

What is the benefit of using dependency injection. Mostly ease of testing. You don’t need to mock myObj and intercept Factory call. Just pass the object as an argument