Arrays

Contains options to control the wrapping behavior for arrays.

Figure 2.40. Arrays settings page

Arrays settings page

Wrap as needed

Enabling this option means cause line breaks to be inserted, whenever an element would otherwise exceed the maximal line length limit.

Example 2.245. 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.246. All elements fit into line

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

Example 2.247. 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 line break after every n-th element.

Example 2.248. 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.249. 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: