Stack using array

public StackUsingArray ( )
{ this(DEFAULT_CAPACITY);

}
explain the statement inside the constructor?

@Mansi
Default Capacity refers to the Capacity we provide while initializing our stack.
we are calling this with parameters of default capacity.
And Default Capacity is provided by user while using the Stack or at the time of initialization of stack in main.

can we call constructor by using this keyword?

In dynamic stack we have made object of stackusingarray so how it will call the metod dynamic stack?

give some response ?

constructor is called when an object is created…
moreover your doubt is not clear can you please elaborate?

In dynamic stack we have made object of stackusingarray so how it will call the metod dynamic stack?

can you pls share the code once…and also please tell about the methods which are being called

how to share the code?

copy paste here in replies

package oops; public class dynamicstack extends stackusingarray{ public dynamicstack() throws Exception{ this(DEFAULT_CAPACITY); } public dynamicstack (int capacity) throws Exception { super(capacity); } public void push (int item) throws Exception { if(this.size()==this.data.length) { int [] arr = new int[2*this.data.length]; for(int i=0;i<this.size();i++) { arr[i]=this.data[i]; } this.data=arr; } super.push(item); } }

package oops; public class dynamicclient { public static void main(String[] args) throws Exception { // TODO Auto-generated method stub stackusingarray stack = new dynamicstack(5); for(int i=1;i<=5;i++) { stack.push(i*10); stack.display(); } stack.push(30); stack.push(80); stack.display(); } }

in this we have made object of stack using array and we have created memory for dynamic stack so how it will call push method of dyanmic stack ?

we will make an object of dynamic stack then it will call the push function of dynamic stack class…it will check if the array is full or not…then by writing super.push() we call the push function of the inherited class

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.