私は次のクラスを持っています:
public class Profile{
String name, age, location;
}
次に、次のコードがあるとします。
ArrayList<Profile> profiles = somePopulatedArrayList;
Profile profile = profiles.get(1);
profile.name = "New name here";
私の質問は、上記.name
の場合、ArrayList 内のオブジェクトが更新されているか、またはここで完全に新しいオブジェクトを作成し、ArrayList に格納されているオブジェクトがまだ古い名前の.name
ままで、そのオブジェクトののみを変更しているのかということです。Profile
ArrayList 内のオブジェクトのプロパティを編集しようとしていますが、上記のアプローチが正しいかどうか疑問に思っていますか?