The previous answer is incomplete. The relationship between frequency and energy applies only to electro - magnetic waves, and can only be understood in terms of the 'wave-particle duality' of light. All types of wave contain energy, as in the waves of the sea. However, the electro - magnetic waves that are light have a particular property that makes them different to other waves, the WAVE-PARTICLE DUALITY. Waves have certain properties that particles do not have, and particles have properties that waves do not have. Waves can be refracted when passing from one medium to another with different density, as in the well known apparent bending of light when a straight stick is immersed in water, and appears to be bent where it passes from air to water. A particle can have varying amounts of energy depending on its speed of motion, pressure and temperature. The discovery of the photoelectric effect showed that when light of a certain frequency falls on a photoelectric substance, the electrons that are caused to flow will always have energy that is proportional to the frequency of the light, and can only have this one value. This led to the conclusion that light acts like specific particles, called PHOTONS. A photon is considered to have energy but no mass, and the relationship between energy and frequency relates to the energy of the photon for that particular frequency. The constant of proportionality was worked by by a guy called PLANCK, so is known as Planck's constant, and is denoted in Physics by the letter h.
The formula E=hf gives the energy of a photon in Joules for a wave of frequency f Hertz.
The wavelength (lambda) does not appear in this equation, as wavelength = speed of light(c) divided by frequency(f), or frequency = speed of light divided by wavelength,so the equation could be written as E = h times c divided by lambda, which would yield the same result