Iron ship has less density than an iron ball. The difference in their volumes is the cause that ship floats and the iron ball sinks.
Let the ship and the iron ball have the same mass. We know,
This equation means that Density is inversely proportional to Volume of the body.
Thus, when the volume of the ship is more (because it is hollow) the density will be less than the density of an iron ball (which is not or less hollow).