In a covalent compound, atoms are held together by the sharing of electrons, whereas in an ionic compound, atoms are held together by the electrostatic attraction between positively and negatively charged ions.
In methane, the carbon atom shares its four valence electrons with the four hydrogen atoms, each of which contributes one valence electron. This results in the formation of four covalent bonds between the carbon atom and the four hydrogen atoms, resulting in a stable molecule.