What is the difference between this initialization methods?

后端 未结 2 1295
再見小時候
再見小時候 2021-01-18 21:54

What is the difference between this two codes?

class SomeClass   
{   

   SomeType val = new SomeType();   

}   

and

<         


        
2条回答
  •  离开以前
    2021-01-18 22:36

    The first version allows you to define multiple constructors without having to remember to put the = new SomeType() in each one.

提交回复
热议问题