- #1
whitehorsey
- 192
- 0
In the main activity, I call one of the constructors:
public Something()
{
//nothing initalized
}
public Something(7 variables)
{
... (this.variable = variable)
}
public Something(10 variables)
{
... (this.variable = variable)
}
I call the 7 variable one but the program won't run and I think its because of overloading. I read that we're suppose to set the first constructor to this(variable, variable, variable, etc); But an error occurs saying the global variables have to be static and when I do change them to static the other two constructors (the ones initialized) says error that the variables can't be static. Is there a better way to handle multiple constructors?
public Something()
{
//nothing initalized
}
public Something(7 variables)
{
... (this.variable = variable)
}
public Something(10 variables)
{
... (this.variable = variable)
}
I call the 7 variable one but the program won't run and I think its because of overloading. I read that we're suppose to set the first constructor to this(variable, variable, variable, etc); But an error occurs saying the global variables have to be static and when I do change them to static the other two constructors (the ones initialized) says error that the variables can't be static. Is there a better way to handle multiple constructors?