The First Law of Thermodynamics, the total energy of an isolated system is constant; energy can be transformed from one form to another, but can be neither created nor destroyed.
, the change in the internal energy ΔU of a closed system is equal to the amount of heat Q supplied to the system, minus the amount of work W done by the system on its surroundings.
Energy is related to mass from Einstein's famous equation E = m*c^2.
I hope this helps, Joe.