When passing an object as a parameter to a method, the link must be copied. Then why the output is 0 9 9 , and not 9 9 9 ? It turns out, s1 and s2 refer to different objects?
public class Main { public static void main(String[] args) { Integer s = 0; foo(s, s = 9); System.out.println(s); } static void foo(Integer s1, Integer s2) { System.out.println(s1); System.out.println(s2); } }