0
How can I do this recursive?
I want to change this method from iterative to recursive public Object elimina(){ if(a == -1){ sout(âcola vacĂaâ); return null; } else { Object aux = cola[0]; for(int i = 0; i < a; i++){ cola[i] = cola[i + 1]; } a- -; return aux; } } I tried this public Object elimina(int i){ if(a == -1){ sout(âcola vacĂaâ); return null; } else { Object aux = cola[0]; if(i < a){ cola[i] = cola[i + 1]; elimina(i + 1); } a- -; return aux; } }
9 Answers
0
just practice, to know more about how recursivity works, but iâve got stuck here in this problem, could you help me? :)
0
Abol the context is that im doing a static queue, the for just travel the whole queue to delete the first one. for example I queue the numbers 1,2,3,4 and 5. following the queue concept the first i have to unqueue is the 1, wich my program do, but it also get a null and the sout(pila vacia)
0
sorry for not explainig haha, sout means System.out.println();
0
yeah it worked! thank you so much! đ€©



