OCJP 認定のシミュレーションで、次の質問を見つけました。
1. StringBuffer s1 = new StringBuffer("abc");
2. StringBuffer s2 = s1;
3. StringBuffer s3 = new StringBuffer("abc");
How many objects are created ?
彼らは、次のように述べているため、正解は 4 であると述べています。
s1 is one object, s2 is another object,
s3 is another object and "abc" is another String Object .
しかし、私にとっては間違っていて、s1
とs2
が同じオブジェクトであるため、3 である必要があります。どう思いますか?