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
[edit | edit source ]Most of the time a page from the Java Programming Wikibook has a structure that looks like this:
<noinclude>{{Displaytitle|title=The title of the page}} {{Nav}} {{Java Programming/LanguageFundamentalsTopic/Nav}} __NOTOC__</noinclude> This is the introduction. ==First section== This is a section. <noinclude> {{Nav}} {{Status|50%}}</noinclude>
- 100% developed as of Dec 31, 2012 Statements
- 100% developed as of Mar 10, 2013 Conditional blocks
- 100% developed as of Mar 10, 2013 Loop blocks
- 100% developed as of May 24, 2013 Boolean expressions
- 100% developed as of Feb 16, 2010 Variables
- 100% developed as of Mar 10, 2013 Primitive Types
- 100% developed as of Mar 10, 2013 Arithmetic expressions
- 100% developed as of May 24, 2013 Literals
- 100% developed as of Mar 10, 2013 Methods
- 100% developed as of May 24, 2013 String
- 100% developed as of Mar 10, 2013 Objects
- 100% developed as of Jul 5, 2012 Packages
- 25% developed as of Sep 21, 2025 Modules
- 100% developed as of Mar 10, 2013 Arrays
- 75% developed as of Jan 11, 2013 Mathematical functions
- 75% developed as of Jan 11, 2013 Large numbers
- 75% developed as of Jan 11, 2013 Random numbers
- 100% developed as of Apr 8, 2013 Unicode
- 100% developed as of Apr 8, 2013 Comments
- 100% developed as of Sep 27, 2007 Keywords
- 100% developed as of Aug 6, 2013 Coding conventions
- 0% developed as of Mar 26, 2018 Lambda expressions
This is the introduction.
First section
[edit | edit source ]This is a section.
Samples
[edit | edit source ]Java file
[edit | edit source ]Sometimes we wish to convey an entire java file, this can be done as follows:
{{XCode|1='''Code listing 1.1: The <code>MyClass</code> class''' <syntaxhighlight lang="java"> class MyClass{} </syntaxhighlight>}}
MyClass
class
class MyClass{}
"1.1" means that it is the first code of the first chapter. Using <syntaxhighlight/>
is better than using a template as ||
is a part of the Java syntax.
Snippets
[edit | edit source ]When just a small section of code is shown, the code template may be used as follows:
{{XExample|1='''Code section 1.1: The <code>MyClass</code> class''' <syntaxhighlight lang="java"> for (int i=0; i<10; i++) { System.out.println("Hello!"); } </syntaxhighlight>}}
MyClass
class
for(inti=0;i<10;i++){ System.out.println("Hello!"); }
Screen print
[edit | edit source ]To represent what is shown on the screen, use the following syntax:
{{XConsole|1='''Output for the application''' <pre style="background-color:#000; color:#fff;"> Hello World! </pre>}}
Hello World!
Notes
[edit | edit source ]Notes grant readers additional information about a certain topic. You can enter additional or side notes by using the following template:
{{XNote|This is an additional note.}}
Use notes only when it is necessary. A note is less readable than paragraphs.
Warning
[edit | edit source ]To warn the user of things like common pitfalls, the XWarning
template should be used as demonstrated:
{{XWarning|This is a warning.}}
To-do items
[edit | edit source ]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:
{{TODO|To-do items for pages should be kept in their respective comment boxes.|Java Programming}}
To do:
To-do items for pages should be kept in their respective comment boxes.
Hidden section
[edit | edit source ]If a section is optional, it can be hidden like this:
{{Java/Hidden begin|title=Hidden section}} This section is not mandatory. {{Hidden end}}
This section is not mandatory.
Illustrations and diagrams
[edit | edit source ]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 #2a7fff
(as is shown for the diagrams below, for instance). In order to include illustrations into your content, you need to use the {{Java/Illustration}}
template. Given below is an example of how this template ought to be used.
{{Java/Illustration |number=1 |caption=A sample illustration from the book |image=[[File:Java Compilation Basics.svg|center]] }}
Text formatting
[edit | edit source ]- Use italic when you use a term for the first time.
- Use the
<code/>
markup when you refer to a class, a field or a method.
Preferred English
[edit | edit source ]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., color
, etc. You should use the US English wherever possible.
Code conventions
[edit | edit source ]The book follows the official Java code conventions. Here is an example:
if(foo==bar){ // do stuff }else{ // do other stuff }