Energy density means the energy stored in the body per unit volume.
It's is given by:-
E
d=1/2
oE
2K.
Where,
E=electric field in the region.
K=dielectric constant of the medium.
this concept cen be used to calculate the energy density of the body by simply multiplying it with the volume of the body provided the electric field due to body in that region is constant.
in case of varying electric field(like a charged sphere) we have to consider a small volume and then find the energy contained in that samll volume and then finally integrate it for finding the energy of the body.
The energy inside the sphere is given as:-E
D=Q
2/(40


R).
and the energy outside the sphere is given as:-E
D=Q
2/(8


R).
Im not getting this.
hope it is clear now.