this(DEFAULT_CAPACITY) in StackUsingArraays CTOR

sir in normal ctor
syntax is:
public StackUsingArrays(int capacity)throws Exception {
if(capacity < 1) {
throw new Exception(“Invalid Size”);
}

	this.data = new int[capacity];
	this.top = -1;
}

///but why in default ctor

public StackUsingArrays() throws Exception {
this(DEFAULT_CAPACITY);
}

//////and not
public StackUsingArrays() throws Exception {
this.data = new int[DEFAULT_CAPACITY];
this.top = -1;

}

Hi Abhishek
You can do it as well but in the above default constructor we are using the already implemented parametrized function and you want to write the same lines of code again in the default constructor. It is correct but redundant. Functions are used to reduce the redundant of lines of code that is used several times.

Hey Abhishek, as you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.