1================= 2Java Coding style 3================= 4 5- We use the `Java Coding 6 Style <https://www.oracle.com/technetwork/java/codeconvtoc-136057.html>`__. 7 Quick summary: 8 9 - FirstLetterUpperCase for class names. 10 - camelCase for method and variable names. 11 - One declaration per line: 12 13 .. code-block:: java 14 15 int x, y; // this is BAD! 16 int a; // split it over 17 int b; // two lines 18 19- Braces should be placed like so (generally, opening braces on same 20 line, closing braces on a new line): 21 22 .. code-block:: java 23 24 public void func(int arg) { 25 if (arg != 0) { 26 while (arg > 0) { 27 arg--; 28 } 29 } else { 30 arg++; 31 } 32 } 33 34- Places we differ from the Java coding style: 35 36 - Start class variable names with 'm' prefix (e.g. 37 mSomeClassVariable) and static variables with 's' prefix (e.g. 38 sSomeStaticVariable) 39 - ``import`` statements: 40 41 - Do not use wildcard imports like \`import java.util.*;\` 42 - Organize imports by blocks separated by empty line: 43 org.mozilla.*, android.*, com.*, net.*, org.*, then java.\* 44 This is basically what Android Studio does by default, except 45 that we place org.mozilla.\* at the front - please adjust 46 Settings -> Editor -> Code Style -> Java -> Imports 47 accordingly. 48 - Within each import block, alphabetize import names with 49 uppercase before lowercase. For example, ``com.example.Foo`` is 50 before ``com.example.bar`` 51 52 - 4-space indents. 53 - Spaces, not tabs. 54 - Don't restrict yourself to 80-character lines. Google's Android 55 style guide suggests 100-character lines, which is also the 56 default setting in Android Studio. Java code tends to be long 57 horizontally, so use appropriate judgement when wrapping. Avoid 58 deep indents on wrapping. Note that aligning the wrapped part of a 59 line, with some previous part of the line (rather than just using 60 a fixed indent), may require shifting the code every time the line 61 changes, resulting in spurious whitespace changes. 62 63- For additional specifics on Firefox for Android, see the `Coding 64 Style guide for Firefox on 65 Android <https://wiki.mozilla.org/Mobile/Fennec/Android#Coding_Style>`__. 66- The `Android Coding 67 Style <https://source.android.com/source/code-style.html>`__ has some 68 useful guidelines too. 69