I have two constructors, which the first one creates some process, like create new objects and without if\for statements. and this constructor cannot be changed, even to private.
But the second constructor get an int value and works like if negative throw exception if positive do some process but if num=0 to avoid duplication of code I want to call first constructor.
What is the right method to implement code like this? Note that these constructors are in the same class.
public class SomeClass{
public SomeClass() {
//Do some process
}
public SomeClass(int num) {
if (num == 0) {
this(); //here we have an issue
}
}
}