Java では、すべてのメソッドは値渡しですが、今日、コンストラクターは参照渡しであることを知りました。
// Attack the internals of a Period instance
Date start = new Date();
Date end = new Date();
Period p = new Period(start, end);
end.setYear(78); // Modifies internals of p!
これは機能し、プライベート フィールドを編集できます。
この決定の理由は何ですか?または私は何かを逃していますか?