Earthworms are hermaphrodites, which means they have both male and female reproductive organs. During mating, two earthworms will line up head-to-tail with their bodies pressed together. They then exchange sperm packets, which they can store for several months before fertilizing their own eggs. The earthworms then go their separate ways and can each lay eggs in a cocoon they produce. The cocoon is usually deposited in soil and can contain anywhere from 1 to 20 eggs, depending on the species. After about three to four weeks, tiny earthworms hatch from the eggs and begin feeding on organic matter in the soil.