They are not the same but they tend to be described together, hence the confusion.
Inversion of Control (IoC) means that objects do not construct other objects on which they rely on. Instead, the application will get these objects from an external framework (an IoC container). One method which provides these objects to the application is called Dependency Injection (DI).
IoC really means that code that doesn't have business logic drives code that contains business logic. A simple example is Servlet:- Technically, the way web container loads and uses servlets is IoC (even though the concepts of Servlets predates popular use of the term) The web container that contains logic for serving HTTP requests is calling the servlet. If you would do this in a non IoC way then you would have a HTTP Parser class and some sort of socket communication class that your servlet will call to listen for HTTP requests. Doing it the non-IoC also means that the generic code is not a container so it can't provide functionality like thread management, etc. Technically, you can have IoC without DI. The servlet container doesn't have DI.. but it does IoC
Technically, you can have DI without IoC, too. DI basically means that there is a module that is responsible for initializing all objects in the system. ALso, when objects are dependent on other objects, the DI module will give reference of objects to objects:- basically this process is called injection of dependencies. If A depends on B, the DI module will initialize A, initialize B, and give the reference of B to A:- the DI module has injected B into A. Now, technically, you could implement your own module that has intimate knowledge of the structure of your program. You can call the DI module from your init/main method and all of your objects will be created. Techncially, this is still DI, just not a very good one, because all the rules for constructing the objects is "hardcoded"
IoC and DI just maike sense together. IoC needs some sort of factory pattern, and using DI solves a lot of problems.
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad: