What are syntactically parallel elements in Java?

There is a rule " 4.5.2 indentation lines with at least +4 spaces " in the Google Java Style Guide, which states:

In general, two continuation lines use the same level of indentation if and only if they start with syntactically parallel elements.

Can someone explain what “ syntactically parallel elementsmean and provide some examples for this case?

+4
source share
2 answers

Google Style Style, , , , . () , .

1 ( ):

foo("bar"
    + "baz"
    + "boo");

2 ( ):

foo("bar"
    + foo2("bar"
        + "baz"));

2 foo2() foo(), foo2() , foo(), : " ".

Google Java , + "baz")); 4 .

, , " " ; , , - .

+1

, , , . .

String[] elements = new String[] { "bob",
                                   "joe",
                                   "pete" };

( ), String .

 {
    System.out.println("hi");
    actNow(input);
    for (int i = 0; i < j; i++) {
      return 5;
    }
 }

System.out.println("hi");, actNow(input);, for , . , return 5; , for. , return 5; - .

0

All Articles