Pair sum 1-d array

Here in else if and else condition why we have updated lower index( j) in else if, what if we decrease i , will code will work.
i mean to say that can we reverse the conditions in else if and else block

In a sorted array, reverse conditions in the else-if and else blocks disrupt the pair sum logic. Adjusting indices correctly ensures all pairs are checked.