I decided to use setters instead of inserting arguments into the default constructor, because it helps me better organize the code
The problem is that the only variable in the project that I am doing is String, and I'm not sure whether it should be initialized in the declaration (as a global variable?), In the setter instance method, or initialized in the class constructor.
I am wondering if there might be something problematic in this setting, whether the instance will not be initialized until its setter is used:
class MyClass{
private String myString;
public MyClass(){
}
public void setStuff(String s){
this.myString=s;
}
}
source
share