According to Archimedes' principle, a body dropped in a liquid displaces an amount of the liquid that is equal to the volume of the body itself.
Thus, by knowing the weight of the body, we can calculate its mass too.
We know that density = MassVolume
And knowing the mass and volume, we can calculate the density of the body.