The energy of the magnetic field results from the excitation of the space permeated by the magnetic field. It can be thought of as the potential energy that would be imparted on a charged particle moving through a region with an external magnetic field present.
A generator converts mechanical energy to electrical energy by magnetic induction when the mechanical energy is used to rotate a loop of wire placed in an external magnetic field.
As a result of the induced magnetic field inside an inductor of inductance L when a current, i, flows through, energy is said to be stored in the magnetic field of the inductor.
In an LC oscillator, the energy is past back and forth from the magnetic field of the inductor to the electric field of the capacitor.
An LC oscillator consists of an inductor and a capacitor passing energy back and forth without dissipation. A capacitor with capacitance C is initially charged to q0 before being attached to an inductor of inductance L. What is the current when the charge has decreased to half its initial value?
Since energy is not dissipated, employ conservation of energy.