I am trying to create an array of stacks but I am getting an error as follows :
" array required, but Main.StacksUsingArrays found
StacksUsingArrays [] B = mainobj.new StacksUsingArrays(N)[Q]; "
What to do??
By the way I am using the StackUsingArray Class created by me.
Playing with cards
Use StackUsingArrays[] arr = new StackUsingArrays [size];
What you are doing wrong is you are creating an instance of StackUsingArray class and assigning it to an array reference which is not possible.
But what will be the size of each stack??
As it is not a dynamic stack.
This is the code. Yeah , that array statement (which you gave) worked perfectly in ECLIPSE ide.
But I am still facing run errors. Please look into the code.
for(int I =0;I< array_size;I++){
StackUsingArrays [I] = new StackUsingArrays(stack_size);}
This initializes each stack individually.
It’s still giving errors.
Please edit the code and add a small comment just next to it.
Here is your code with no compile time errors, but your code still gives runtime error. It is because you are trying to remove elements from stack on underflow condition. Please correct your code by finding that bug. If you face difficulty, ask me.
Yeah !!
It works perfectly now.