While Enqueing & displaying data using Stack, how (ai) available index variable line is working or getting data

int ai = (this.front + this.size()) % this.data.length;

front represents the starting index of the elements that are filled in the array and size represents the no. of elements in the array at that particular instant of time, so to calculate the next available index you do just start + size

but front is returning always 0

no front stores the index of the next element to be dequeued

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.