You are on page 1of 26
 
Java
 Coding Style Guide
 Achut Reddy
Server Management Tools GroupSun Microsystems, Inc.
Created:January 27, 199Last modified:May 30, 200
 ABSTRACT 
The importance and benefits of a consistent coding style are well known. This document describes a set of codingstandards and recommendations for programs written in the Java
 language. It is intended for all Java software de-velopers. It contains no material proprietary to Sun, and may be freely distributed outside Sun as well.Feedback in the form of corrections or suggestions for improvement are welcomed. Comments may be sent to
achut@eng.sun.com
.
 
Table of Contents
Java Coding Style GuideiTable of Contents
package
 declaration.............................................................................................32.2.3
import
 declarations.............................................................................................32.2.4
class/interface
 declarations...........................................................................3
 not 
................................................................................................................................106.1 Class body organization................................................................................................116.1.1 Member access levels..........................................................................................116.1.2 Member documentation comments......................................................................116.1.3 Class and instance variable field declarations.....................................................116.1.4 Static initializer....................................................................................................126.1.5 Static member inner class declarations................................................................126.1.6 Static method declarations...................................................................................126.1.7 Instance initializer................................................................................................126.1.8 Constructor declarations......................................................................................126.1.9 Instance method declarations...............................................................................136.2 Method declarations......................................................................................................136.3 Local inner classes........................................................................................................14
 
Table of Contents
Java Coding Style GuideiiTable of Contents
...........................................................................................................................157.1 Interface body organization..........................................................................................16
return
if
 statement........................................................................................................188.2.4
for
 statement......................................................................................................188.2.5
while
 statement...................................................................................................188.2.6
do-while
 statement.............................................................................................188.2.7
switch
statement................................................................................................188.2.8
try
 statement.......................................................................................................198.2.9
synchronized
statement....................................................................................198.3 Labeled statements........................................................................................................19
................................................................................................................................20

Reward Your Curiosity

Everything you want to read.
Anytime. Anywhere. Any device.
No Commitment. Cancel anytime.
576648e32a3d8b82ca71961b7a986505