Arrays

Contains options to control the general wrapping behavior for arrays.

Wrap as needed

Enabling this options means array elements will be wrapped so that they will be limited within the current maximal line length.

Example 2.451. Wrap as needed

String[] s = new String[] {              |
    "first", "second", "third", "fourth",|
    "fifth", "sixth", "seventh",         |
    "eighth", "ninth", "tenth",          |
};                                       |
Wrap all when exceed

Forces a line break after every array element when all elements would not fit into the current line limit.

Since 1.7

Example 2.452. All elements fit into line

String[] s = new String[] {                                           |
    "first", "second", "third", "fourth", "fifth", "sixth", "seventh",|
};                                                                    |

Example 2.453. Wrap all elements when line would get exceeded

String[] s = new String[] {                                           |
    "first",                                                          |
    "second",                                                         |
    "third",                                                          |
    "fourth",                                                         |
    "fifth",                                                          |
    "sixth",                                                          |
    "seventh",                                                        |
    "eighth",                                                         |
};                                                                    |
Wrap after element

Forces a new line after every n-th element.

Example 2.454. Wrap after element 1

String[] s = new String[] {    |
    "first",                   |
    "second",                  |
    "third",                   |
    "fourth",                  |
    "fifth",                   |
    "sixth",                   |
    "seventh",                 |
    "eighth",                  |
    "ninth",                   |
    "tenth",                   |
};

Please note that no checking is done regarding the maximal line length limit which might easily lead to lines exceeding the maximal line length when you set n to something bigger than '1'.

Example 2.455. Wrap after element 3

String[] s = new String[] {    |
    "first", "second", "third",|
    "fourth", "fifth", "sixth",|
    "seventh", "eighth", "ninth",
    "tenth",                   |
}                              |

If neither option is enabled, the array elements will be printed in one line, right after the left curly brace, i.e. automatic line wrapping will be disabled.

Please note that you can further customize the wrapping behavior for arrays with the following options: