Doubt regarding Even-After-Odd problem in Linked List

This is my code .
public void evenAfterOdd() throws Exception {

	Node temp = head ;
	int i = 0 ; int counter = 0 ;

	// counting number of even elements
	while(temp.next != null){
		if(temp.data % 2 == 0){
			counter ++ ;
		}
		temp = temp.next ;
	}
	temp = head ;
	int count = 0 ;
	// moving all even elements to end
	while(count < counter) {
		boolean visited = false ;
		if(temp.data % 2 == 0){
			visited = true ;
			int rv =removeAt(i) ;
			addLast(rv) ;
			count ++ ;
		}
		if(visited){
			temp = getNodeAt(i) ;
		}
		else{
			i++ ;
			temp = temp.next ;
		}
	}

}
Only 1 test case is failing for the code I have written . Can you tell me for which sequence of elements is my code failing ?

@Lalit2142,
6
2 4 3 8 5 6

your output: 3 5 6 2 4 8
correct output: 3 5 2 4 8 6

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.