software engineering, dependency injection is a technique whereby one object (or static method) supplies the dependencies of another object. ... In Java, before we can use methods of other classes, we first need to create the object of that class (i.e. class A needs to create an instance of class B).