超基本的な質問のように感じますが、頭を包むことはできません。
クラス PriceGroup があり、オブジェクトを作成しているコンストラクターはありません。
class SmallPortfolio{
String id;
// all the investments (stocks) belonging to this portfolio.
List<Investment> invList = new ArrayList<Investment>();
}
別のクラスで、Spor という名前の SmallPortfolio オブジェクトを作成しています。
//
String id = InstanceID.getTextNormalize(); //this value is taken from an element from jdom.
SmallPortfolio Spor;
Spor.id = id;
//some code that creates a list of investments
//some code that creates a list of SmallPortfolio objects
Javaでは、nullオブジェクトのフィールドにNullPointerExceptionで取得した値をどのように与えるのですか? 別の解決策は、null ではない SmallPortfolio オブジェクトを宣言することです。
奇妙な問題ですが、私が使用しているテスト プログラムは変更できず、SmallPortfolio のコンストラクタもありません。