Netbeans Java Code Formatting Issues

I would like some of the Java code snippets to be formatted more compactly than the default behavior for Netbeans, however I could not set the Netbeans formatting options for the code snippets below, so I will try to ask here:

1 / Is it possible to set Netbeans formatting to leave the single line method as it is? For instance:

public void printMessage(String message) { System.out.println(message); }

the default behavior formats this snippet, as shown below:

public void printMessage(String message) {
    System.out.println(message);
}

2 / Is it possible for a double curly bracket to be initialized in this form?

private List<String> list = new ArrayList<String>() {{
    // some code here
}};

Netbeans always breaks this code into

private List<String> list = new ArrayList<String>() {
    {
        // some code here
    }
};

Thanks for the tips.

+4
source share

All Articles