// Most Javadoc left out for brevity! import java.io.*; import java.util.*; import com.jthreadkit.*; public class QuickExample extends Object implements Comparable, Serializable { public static final int NO_ALIGNMENT = 1; private int count; private int numStudents; private String[] name; public QuickExample( int param, String stuff, double otherThings, boolean useShortcut ) throws IllegalArgumentException { this.count = param + 25; // ... } public QuickExample(int param) throws IllegalArgumentException { this(param, null, 0.0, true); } public void someMethod() { if ( boolExprA ) { // ... } else if ( boolExprB ) { // ... } else { // ... } for ( int i = 0; i < str.length; i++ ) { // ... } while ( blah ) { // ... } synchronized ( this ) { // ... } try { // ... } catch ( XYZException x ) { x.printStackTrace(); } finally { // ... } switch ( expr ) { case 'A': case 'X': // ... break; default: break; } button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // ... } }); } /** * Calculates the complicated thing and returns the result * of the stuff... * * @return a negative number indicating... */ public int process() { // ... } public static void main(String[] args) { // ... } } |
Items to take note of:
{
' are at the end of a line, and the
corresponding closing brace '}
' is directly under the
first character of the line that opened the brace. Compound
structures close the brace and then open a new one on the same
line, ex: "} else {
". All code within the curly
brace block is indented one level. Curly braces are always used even
for single statement blocks.
NO_ALIGNMENT
are in all capitals
with underscores breaking up words.
double[] value
".
Sun Microsystems' Source Code Style Conventions (at java.sun.com) blockquote>
[ Back ] [ Programix Home ]