I learn Java and wonder if there any difference between following implementation of class initialization.
[OPTION 1]
public class LaunchHandler implements SomeItf{
public static LaunchHandler create(ArrayList<String> params){
LaunchHandler self = new LaunchHandler(params);
return self;
}
private LaunchHandler(ArrayList<String> params){
mParams = params;
}
}
So I call it as:
SomeItf launch = LaunchHandler.create(params);
[OPTION 2]
public class LaunchHandler implements SomeItf{
public LaunchHandler(ArrayList<String> params){
mParams = params;
}
}
I call it as:
SomeItf launch = new LaunchHandler(params);
For me both options do the same but 1st option I saw it in big project.
What is the advantage of 1st Option?
Can somebody spread the light?