JDK 1.1 for Solaris Developer's Guide

Code Optimization

Loops

Use these techniques for performance improvements:

Convert expr to Table Lookup

When a value is being selected based on a single expression with a range of small integers, convert it to a table lookup. Conditional branches defeat many compiler optimizations.

Caching

Though caching takes more memory, it can be used for performance improvement. Use the technique of caching values that are expensive to fetch or compute.

Precompute Results

Increase performance by precomputing values known at compile time.

Lazy Evaluation

Save startup time by delaying computation of results until they are needed.

Class as Opposed to Object Initialization

Speed performance up by putting all one-time initializations into a class initializer.