A JAVA interview question, I don't quite understand about int and Integer,String and StringBuffer,.

the title is like this.

public class T_Three {
    public void increment(int a, Integer b, String c, StringBuffer d) {
        aPP;
        bPP;
        c = c + " world";
        d.append(" world");
    }

    public static void main(String[] args) {
        int a = 0;
        Integer b = new Integer(0);
        String c = "hello";
        StringBuffer d = new StringBuffer("hello");
        new T_Three().increment(a, b, c, d);
        System.out.println("a=" + a + " b=" + b + " c=" + c + " d=" + d);
    }
}

ask the result of the output
await? Baked? Che? Dumped?

then I tried it on IDE. The result of the output is

axi0 c=hello d=hello world
May I ask why? Why didn"t the self-increase of an and b increase? Why String is not spliced, why does StringBuffer"s append work?

Stringbuffer I personally understand that what append operates is the incoming object, so it works on it.
c is not concatenated because it operates on the c of the function itself and does not affect the outer c.
but I don"t quite understand Integer and int.

I don"t know if I understand it correctly. I hope you can give me some guidance.

Mar.23,2021

a _ line c is a value passed, so a _ line c in a function is a copy of a _ line c. B, d are pass references, but the value of Integer is immutable, itself cannot be changed. So only the value of d will change.


are all value passing. Needless to say about this. Although b is an object and passes a reference to the method, it does not change what the reference points to in the method, but changes the value of the reference. C is the same thing. D is different, changing what the reference points to.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea6b89-6956d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea6b89-6956d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?