***
### What Is Dependency Injection?
Dependency injection is a pattern we can use to implement [[Inversion of Control | IoC]], where the control being inverted is setting an object's dependencies.
Connecting objects with other objects, or "injecting" objects into other objects, is done by an assembler rather than by the objects themselves.
```java
public class Store {
private Item item;
public Store() {
item = new ItemImpl1();
}
}
```
In the example above, we need to instantiate an implementation of the _Item_ interface within the _Store_ class itself.
By using DI, we can rewrite the example without specifying the implementation of the _Item_ that we want:
```java
public class Store {
private Item item;
public Store(Item item) {
this.item = item;
}
}
```
***
**References**:
- [Intro to Inversion of Control and Dependency Injection with Spring](https://www.baeldung.com/inversion-control-and-dependency-injection-in-spring)