They have self-inductance that opposes change to current through them
$$ \begin{aligned} \Phi&=\int_S \vec B\cdot \text d \vec A \propto I=LI \\ \mathcal E&=-L\frac{\text{d}I}{\text{d}t} \end{aligned} $$
Same situation as above we can find
$$ B=\mu_0nI \quad ; \quad n=\frac{N}{l} \quad ; \quad \text{For 1 turn: }\Phi=\int_S\vec B\cdot \text d\vec A =BA \\ \begin{aligned} \text{Flux for solenoid: }\Phi&=NBA=\mu_0 NnIA \\ &=LI=\mu_0n^2lIA \\ \Rightarrow \quad L&=\mu_0n^2lA=\frac{\mu_0 N^2A}{l} \\ \Rightarrow \quad M&=\frac{\mu_0 N_1N_2 A}{l} \end{aligned} $$
$$ E_p=\frac{1}{2}LI^2 $$
$$ B=\mu_0nI\Rightarrow I=\frac{B}{\mu_0n} $$
$$ E_p=\frac{1}{2}LI^2=\frac{1}{2}\mu_0 n^2 lA\left ( \frac{B}{\mu_0 n}\right )^2=\frac{B^2}{2\mu_0}lA $$
$$ u_B=\frac{B^2}{2\mu_0} \quad ;\quad u_E=\frac 12 \epsilon_0 E^2 $$
$u_B$ energy density of $B$-field ; $u_E$ energy density of $E$-field