What are the best Java example sites? I'm looking for places that you go when you have a specific question and you want a little Java code snippet to solve it with.
8 Answers
I like Java Almanac (now renamed www.exampledepot.com/). It has great examples and very pertinent questions, but it only goes through java 1.4, so unfortunately it's pretty out of date. It has good coverage of simple questions like "Quintessential Regular Expression Search and Replace Program" and "Reading Text from a File". Also covers some more complicated topics.
Another site I like is javapractices.com. This one answers questions at a little higher level than Java Almanac, for example "Modernize old code" or "Know the core libraries".

- 33
- 1
- 2
- 6
A place I get a lot of samples / answer to questions is the forums of the sun java web site itself. If the answer isn't there, usually users will point you in the right direction.

- 992
- 1
- 8
- 12
I like http://jexamples.com . This has real working code indexed from open source projects. The site also incorporates ratings so the best examples are shown.
I think the good site for examples as well as some tutorials is Java Jazzle or k2java.blogspot.com

- 3,241
- 3
- 33
- 41
I like DZone Snippets from
It is a public source code repository.
You can build up your personal collection of code snippets, and categorize them with tags / keywords.
(just add another suggestion)
Wait a minute...
By re-reading your question... I think this site (i.e. stackoverflow) is the very best place for what you are asking for!
You can publish a problematic java snippet and receive answer.
Case in point : What is the syntax for mod in java
I have to leave you now: I need to check my profile.
I might have just received my first "brown-nose" badge ;-)
-
Damned... the "brown-nose" base has yet to be implemented! I might mentionned it to stackoverflow.uservoice.com... or not ;) – VonC Sep 18 '08 at 05:29