My question is very simple and novice. I have a class, and want to create instance of it. So should I use temporary variables and then assign the values using setters or should I create an object and then directly assign user input to setter.
class A {
int a;
A(){
a=0;
}
A(int a){
this.a=a;
}
}
Now how should I create objects?
- Should I use temporary variables and then use constructor to create object.
- Should I create object and directly assign user input to instance variable. for example
aObj.setA(getUserInput());
Please advice.