Java Programming/Conventions

These conventions are aimed to increase the readability and the comprehension of the Java Programming Wikibook. It completes the Wikibooks Manual of Style. However exceptions can be made if needed. If you find it too complex to follow, add the content rawly. It will be formatted by someone.

Page formatting
Most of the time a page from the Java Programming Wikibook has a structure that looks like this:

{|style="text-align: left; width:100%"
 * style="border-right:1px solid grey; text-align:center;"|You write
 * style="text-align:center;"|You get
 * style="border-right:1px solid grey"|
 * style="border-right:1px solid grey"|

This is the introduction.

First section
This is a section.



This is the introduction.

First section
This is a section.


 * }

Java file
Sometimes we wish to convey an entire java file, this can be done as follows:

"1.1" means that it is the first code of the first chapter. Using  is better than using a template as   is a part of the Java syntax.

Snippets
When just a small section of code is shown, the code template may be used as follows:

Screen print
To represent what is shown on the screen, use the following syntax:

Warning
To warn the user of things like common pitfalls, the  template should be used as demonstrated:

To-do items
If there are sections of the book that require attention at a later time, you can add a to-do note by including the following template:

Hidden section
If a section is optional, it can be hidden like this:

Illustrations and diagrams
This book uses various illustrations and diagrams to convey its message, e.g., flow-chart or UML diagrams, etc. Due to the nature of diagrams, they need to be designed in a scalable vector format. It is highly recommended that you use the SVG format for your diagrams. Please, do not use JPG or PNG for diagrams that could otherwise be done in SVG. Ask a regular contributor for his/her help in this matter.

A regular feature for diagrams used in this book is the overall color scheme. The most notable color used for illustrations in this book is   (as is shown for the diagrams below, for instance). In order to include illustrations into your content, you need to use the  template. Given below is an example of how this template ought to be used.

Text formatting

 * Use italic when you use a term for the first time.
 * Use the  markup when you refer to a class, a field or a method.

Preferred English
This book uses United States English, purely for the sake of consistency. Most programming languages have words represented in the United States English, e.g.,, etc. You should use the US English wherever possible.

Code conventions
The book follows the official Java code conventions. Here is an example: