When you touch a hot stove, thermal energy enters your hand because the stove is warmer than your hand. If you touch a piece of ice, thermal energy flows out of your hand and into the colder ice. The quantity that tells you how hot or cold something is compared to a standard is temperature. A thermometer measures temperature. The Celsius thermometer bases its scale on the freezing (0 degrees C) and boiling points (100 degrees C) of water.
When you bring a warm and a cool object together, thermal energy transfers in the direction from the warmer object to the cooler object. Heat is defined as the thermal energy transferred from one object to another due to a temperature difference. Since heat is thermal energy in transit, matter contains thermal energy - not heat. Once thermal energy has been transferred to an object, it ceases to be heat. Therefore thermal energy can be thought of as the total internal energy, both kinetic and potential, of the particles that make up a substance.