/** * PAss an object reference in Java * When passed, the var holding the reference can be updated, but that * change is not reflected outsize the function. * This means that the pointer is, in some sense, pass-by-value. * Scott calls this pass by sharing. * @author gtowell * Created: November 2021 */ public class PassRef { public int aa = 5; public static void main(String[] args) { new PassRef().doo(); } public void doo() { PassRef pr = new PassRef(); pr.aa = 7; System.out.println(String.format("PR bef %d", pr.aa)); ado(pr); System.out.println(String.format("PR aft %d", pr.aa)); } private void ado(PassRef pado) { pado.aa = 9; pado = new PassRef(); pado.aa = 99; } }