why can a submarine hang in water

IT adjusts its density by adding or removing water ballast, so that the density of the submarine = density water, and the sub the has no net weight, nor no net upward force.