Code Conventions for the Java TM Programming Language

Revised April 20, 1999

The information on this page is for Archive Purposes Only

This page is not being actively maintained. Links within the documentation may not work and the information itself may no longer be valid. The last revision to this document was made on April 20, 1999

  1. 1 Introduction
  2. 1.1 Why Have Code Conventions
  3. 1.2 Acknowledgments
  4. 2 File Names
  5. 2.1 File Suffixes
  6. 2.2 Common File Names
  7. 3 File Organization
  8. 3.1 Java Source Files
  9. 3.1.1 Beginning Comments
  10. 3.1.2 Package and Import Statements
  11. 3.1.3 Class and Interface Declarations
  12. 4 Indentation
  13. 4.1 Line Length
  14. 4.2 Wrapping Lines
  15. 5 Comments
  16. 5.1 Implementation Comment Formats
  17. 5.1.1 Block Comments
  18. 5.1.2 Single-Line Comments
  19. 5.1.3 Trailing Comments
  20. 5.1.4 End-Of-Line Comments
  21. 5.2 Documentation Comments
  22. 6 Declarations
  23. 6.1 Number Per Line
  24. 6.2 Initialization
  25. 6.3 Placement
  26. 6.4 Class and Interface Declarations
  27. 7 Statements
  28. 7.1 Simple Statements
  29. 7.2 Compound Statements
  30. 7.3 return Statements
  31. 7.4 if, if-else, if else-if else Statements
  32. 7.5 for Statements
  33. 7.6 while Statements
  34. 7.7 do-while Statements
  35. 7.8 switch Statements
  36. 7.9 try-catch Statements
  37. 8 White Space
  38. 8.1 Blank Lines
  39. 8.2 Blank Spaces
  40. 9 Naming Conventions
  41. 10 Programming Practices
  42. 10.1 Providing Access to Instance and Class Variables
  43. 10.2 Referring to Class Variables and Methods
  44. 10.3 Constants
  45. 10.4 Variable Assignments
  46. 10.5 Miscellaneous Practices
  47. 10.5.1 Parentheses
  48. 10.5.2 Returning Values
  49. 10.5.3 Expressions before '?' in the Conditional Operator
  50. 10.5.4 Special Comments
  51. 11 Code Examples
  52. 11.1 Java Source File Example