Example:
class X { Y foo() { return new Y(); } } class Y { X bar() { return new X(); } } void foo() { Y y = new X().foo(); // Chained method call }
Use the inspection options to toggle warnings for the following cases:
chained method calls in field initializers,
for instance, private Y y = new X().foo();
chained method calls operating on the same type,
for instance, new StringBuilder().append("x: ").append(new X()).append("y: ").append(new Y()).toString();
.