Is it possible to call a constructor with the result of a method from another constructor of the same class?
I want to be able to accept input in several forms, and have something like:
public class MyClass
{
public MyClass(int intInput)
{
...
}
public MyClass(String stringInput);
{
this(convertToInt(stringInput));
}
public int convertToInt(String aString)
{
return anInt;
}
}
When I try to compile this, I get
error: cannot reference this before supertype constructor has been called
refering to convertToInt
.