Index out of bound for full recursive solution

I tried running the full recursive code of bubble sort and it gives array index out of bound exception , please check.

Code :

private static void fullRecursiveBubbleSort(List list2, int i, int n) {

	if(n == 1) {
		return;
	}
	
	if(i == n-1) {
		fullRecursiveBubbleSort(list2, 0, n-1);
	}
	if(list2.get(i) > list2.get(i + 1)) {
		Collections.swap(list2, i, i + 1);
	}
	
	fullRecursiveBubbleSort(list2, i+1, n);
}

Hello @arjitgupta2211,

Share the full code using some online IDE.

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.