... | ... | @@ -88,3 +88,31 @@ Examples of labels: |
|
|
|
|
|
## Code
|
|
|
|
|
|
Example of a function:
|
|
|
|
|
|
class GenerateRandom {
|
|
|
|
|
|
public int generateRandom(int param1, int param2) {
|
|
|
int min = param1;
|
|
|
int max = param2;
|
|
|
|
|
|
int random_int = (int)Math.floor(Math.random() * (max - min + 1) + min);
|
|
|
|
|
|
return random_int;
|
|
|
}
|
|
|
|
|
|
public static void main( String args[] ) {
|
|
|
System.out.println(generateRandom(10, 40));
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- Tabwidth is 4 spaces.
|
|
|
- Newline before return sequence, unless it is a oneliner.
|
|
|
- Space between arithmetic operators and parameters.
|
|
|
- Space to the write of commas before more parameters.
|
|
|
- Space before curly brackets: {}.
|
|
|
- First curly bracket on the same line.
|
|
|
- New line before a new function or end of a class.
|
|
|
- Always return a singular variable in a function for better readability.
|
|
|
- Imported items must be in alfabetical order. |