Ensure type safety using enums to restrict values in arguments.
Don't allow null parameters or null return values in your APIs. Return an empty list or an empty object instead.
Don't rewrite the same code multiple times by keeping common functionalities inside superclasses.
Code to interfaces instead than to classes.
Don't write long methods, give to each function a single function.
Create unit tests in the same package being tested, in order to increase the visibility of the items being tested.
Don't use float or double for currencies, use BigDecimal instead.
Use defensive copy to preserve encapsulation, when passing or returning objects to/from a class. Minimize the mutability of a class whenever possible.
Favour copy constructors over cloneable.
Create or initialize objects only when required (lazy loading). Minimize the number of objects.
Avoid public member variables. That also to prevent unsynchronized access.
Declare a variable just before its use.
Always initialize local variables.
Use Java APIs or external libraries, instead of writing your own API.
Whenever possible use primitives instead of wrappers, being less prone to programming errors and being faster.
Never leave a finally block to throw exceptions.
Never throw instances of "Exception".
Minimize synchronization to reduce performance overhead.
Synchronize only critical sections and not all the function, when possible.
Use design patterns whenever appropriate.
Avoid synchronization overhead by not using the same lock on objects that are not manipulated togheter and by not using the same lock for objects that are not accessed concurrently.
Provide a thread-safe wrapper for objects that are not thread safe (refer to the Collection Framework as an example).
Always prefer creating immutable objects, if this doesn't mean allocating a lot of objects that need to be garbage collected.
Don't add additional synchronization to objects that are already synchronized.
Lock objects in the same order to prevent deadlocks.
Never rely on finalize() to release resources.
Discard no more used object references.
Always release resources after handling erros. Use finally clause or try-with-resource for cleanup.
Catch benign errors before generic ones and don't discard the object that threw the exception for the firsts.
Execute only one transaction for request and don't span multiple requests with one transaction.
Don't implement business logic in the client.
If the size is fixed use an array instad of an ArrayList
Use ArrayList and LinkedList instead of Vector; LinkedList instead of Stack; TreeMap and HashMap instead of Hashtable. (the seconds are synchronized, for the firsts use methods like Collections.synchronizedMap(); the seconds synchonize also read methods, so for the firss use synchronized block to iterate).
Reuse objects (pooling etc).
Use StringBuffers instead of String, if you append to a string in multiple statements.
Use StringBuffer instead of String, if you know the size of the string. Then use the constructor to create a buffer with the right size.
Never ignore exceptions with empty catch blocks.
Don't forget to set the root cause of an exception, if present.
Don't code what can be done in SQL (ordering, sub-selection, grouping etc).
Don't write SQL into the code, use separate files.
Use for-each loops or iterators instead of for loops, being less error prone.
Use assertion only on private methods arguments to check assumptions on the internal implementation. Force compliance in public methods for example by throwing exceptions.
Avoid returning local, inner or anonymous classes instances to the outside scope.
Avoid states whenever possible and be functional.
Use a building tool like Maven or Ant.
If you are about to return a null pointer, consider throwing an exception instead.