Note: This article is in the process of being updated--
Resistors or linear constant-current sources are okay for small, low-current LEDs but it's desirable to use a better efficiency switching supply for higher power LEDs.
Here's is a relatively simple switching constant-current supply that uses the common LM339/393 as part of a relatively simple and reasonably high efficiency circuit.
Below is the LTspice simulation of the regulator for up to about 1A LEDs.
It's a...