A Collection of Code Samples From Sun
Be sure to check out this handy reference: the Code Samples wiki from Sun. The many segments are divided by category (Java SE, SE, ME, and FX platforms, scripting languages, and so forth) and then by topic (language syntax, math operations, multimedia, and so forth).
And do share your code by adding to the collection! Wikis are superior for enabling exchanges.