Completing work in constructor VS using an initializer

Viewed 77

From what I have seen in other peoples code, there appears to be two ways common ways in creating an object and "readying" it to be used.

Method 1: Ready the object in the constructor:

public class SomeClass {
  int setting;

  public SomeClass(int setting) {
    this.setting = setting;
  }
}

Method 2: Create the Object then "ready" it inside an initialize method such as:

public class SomeClass {
  int setting;

  public SomeClass(int setting) {

  }

  public void init(int setting) {
    this.setting = setting;
  }
}

Is there any specific reason to use either method over another?

3 Answers
Related