Skip to content

Latest commit

 

History

History
65 lines (60 loc) · 1.6 KB

JAVA_CODE_STYLE.md

File metadata and controls

65 lines (60 loc) · 1.6 KB

Java Code Formatting:

IntelliJ Defaults + Force braces everywhere
OR
Google Java Style with 4 spaces for all tabs

public class Foo {
    public int[] X = new int[]{1, 3, 5, 7, 9, 11};

    public void foo(boolean a, int x, int y, int z) {
        label1:
        do {
            try {
                if (x > 0) {
                    int someVariable = a ? x : y;
                    int anotherVariable = a ? x : y;
                } else if (x < 0) {
                    int someVariable = (y + z);
                    someVariable = x = x + y;
                } else {
                    label2:
                    for (int i = 0; i < 5; i++) {
                        doSomething(i);
                    }
                }
                switch (a) {
                    case 0:
                        doCase0();
                        break;
                    default:
                        doDefault();
                }
            } catch (Exception e) {
                processException(e.getMessage(), x + y, z, a);
            } finally {
                processFinally();
            }
        }
        while (true);

        if (2 < 3) {
            return;
        }
        if (3 < 4) {
            return;
        }
        do {
            x++;
        }
        while (x < 10000);
        while (x < 50000) {
            x++;
        }
        for (int i = 0; i < 5; i++) {
            System.out.println(i);
        }
    }

    private class InnerClass implements I1, I2 {
        public void bar() throws E1, E2 {
        }
    }
}