Java - Initialize a HashMap of HashMaps

前端 未结 4 1695
小蘑菇
小蘑菇 2020-12-17 15:52

I am new to java and practicing by creating a simplistic NaiveBayes classifier. I am still new to object instantiation, and wonder what to do to initialize a HashMap of Has

4条回答
  •  眼角桃花
    2020-12-17 16:23

    You must create an object before using it via a reference variable. It doesn't matter how complex that object is. You aren't required to initialize it in the constructor, although that is the most common case. Depending on your needs, you might want to use "lazy initialization" instead.

提交回复
热议问题