The strength of a gravitational force depends on how much mass is involved, and how far away from it you are. For very dense objects, a lot of mass is concentrated in a very small region of space, so you can get very close to it. The force of gravity is defined as:
G M m
F = --------
2
R
And for an object with a density of D and a radius of r, you get
4 3
M = D x --- pi r
3
so that by substitution:
Gm 4 3
F = ----- x --- pi r D
2 3
R
and so in terms of density:
3
4 pi G m r
F = ----------- D -----
3 2
R
If you are outside the body, R is greater than r and the entire body acts like
a point mass located at R = 0. If you are inside the body, R = r
and the force you feel depends on the total mass in the sphere inside your
radial position from the center. The force of gravity actually decreases
inside such a body as you approach its center, no matter how dense it is.