1
Answer

Difference between instantiate object in class and in constructor of class?

Bojan P

Bojan P

14y
11.8k
1
Is this a same thing? If not, what is the difference?

public class WhatEver{
   SomeClass cl = new SomeClass();
    //constructor
    public WhatEver();
}



public class WhatEver{
    //constructor
    public WhatEver() {
      SomeClass cl = new SomeClass();
     }

}

Answers (1)