public class B { void foo(AAA a) { a.setX(a.getX() + 1); y += "a"; } private String y = ""; public String getYY() { return y; } }