Java Code Templates
From PeacockWiki
Contents |
[edit]
Naming Conventions
[edit]
Class names start with caps
Class MyClass { }
[edit]
Variable names start with lowercase
MyClass myVariable;
[edit]
Method Names start with lowercase
public void myMethod() { }
[edit]
Objects
[edit]
Creating an Object
= new ();
eg.
String myString = new String("MyStringValue");
[edit]
Calling a method of a object
.();
[edit]
Arrays
[edit]
Creating and instantiating an array
[]; = new [];
[edit]
Loops
[edit]
For Loops
for(assignment;comparator;incrementer) { do something here; }
for( = ; [<] ; ++) { do something here; }
this for loop is equivilant to the following while loop
= While( [<] ) { do something here. ++ }
[edit]
Pre-Tested
While is a "pre-tested" loop. The condition is tested before the code block is executed. As a result, it is possible that the code block will never execute.
while(condition) { }
[edit]
Post-Tested
Do is a "post-tested" loop. The condition is tested after the code block is executed. As a result, the code block will always execute at least once.
do { } while(condition)