/** * PAss a reference in Java * identityHashCode might given memory location -- sort of. * Kotlin does not allow changing the reference location of passed param * so the line "pss = "5" "is commented out to make the program compile * * @author gtowell * Created: August 2021 */ public class PassRef { public static void main(String[] args) { String aa = new String("asdf"); System.out.format("Main aaa:%s lod:%d\n", aa, System.identityHashCode(aa)); passer(aa); System.out.format("Main aa:%s lod:%d\n", aa, System.identityHashCode(aa)); } public static void passer(String pss) { System.out.format("passer pss:%s lod:%d\n", pss, System.identityHashCode(pss)); pss = new String("5"); System.out.format("passer pss:%s lod:%d\n", pss, System.identityHashCode(pss)); } }