We know that fire needs oxygen in order to burn. Then how come stars continue to burn even though there is no oxygen in space?
If stars "burned" like giant lumps of coal, you are correct that oxygen would be needed for combustion. Stars like the Sun, however, generate their energy by converting hydrogen to helium in their cores. Although it is true this is sometimes referred to as hydrogen "burning", it is not actual burning like the combustion you see in most fires on Earth. Even with enough oxygen, a lump of coal the size of the Sun could only provide its current energy output for about 50,000 years. We know the Sun has been shining for BILLIONS of years, so a more efficient energy source is being used.
Rather than coal, the Sun is about composed of about 3/4 hydrogen and 1/4 helium. When hydrogen atoms are forced by high pressure and temperature to combine into heavier helium atoms, some mass is lost in the process. That "lost" mass is converted to energy equivalent to mc2, according to Einstein's famous equation. Since c (the speed of light) is a large number, a small amount of mass gets converted into a large amount of energy. This process is called hydrogen fusion, and is the same energy source used in hydrogen bombs.
The Sun converts almost 600 million tons of hydrogen to helium in its core each second, but it is estimated that there is enough hydrogen fuel in the Sun for it to shine for another 5 billion years.
Paul Walorski, B.A., Part-time Physics/Astronomy Instructor
'The difference between what the most and the least learned people know is inexpressibly trivial in relation to that which is unknown.'