My code not working

import java.util.*;
public class Main {
static void swap(int a,int b){
int temp=0;
temp=a;
a=b;
b=temp;
}
static void display(int arr[]){
for ( int i=0;i<arr.length;i++){
System.out.println(arr[i]);
}
}
public static void main(String args[]) {
// Your Code Here.
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int arr[]=new int[n];
for(int i=0;i<n;i++)
{
arr[i]=sc.nextInt();
}
int zero=0,one=0;
int two=n-1;

	while(one<=two)
	{
		switch(one)
		{
			case 0:{
				//swap(arr[zero],arr[one]);
				int temp=arr[zero];
				arr[zero]=arr[one];
				arr[one]=arr[zero];
				zero++;
				one++;
				break;
			}
			case 1:{
				one++;
				break;
			}
			case 2:{
				swap(arr[one],arr[two]);
				// int temp=arr[two];
				// arr[two]=arr[one];
				// arr[one]=temp;
				two--;
				break;
			}
		}
	}display(arr);
}

}

the code is working when i am uisng swap function…but when i remove swap function and use the delibrate code to swap it works fine

@Kshirja Swapping function will not swap the values but deliberate code will do that bcoz when you send some parameters for swapping the changes will not be made in the main function. Refer this Article for more details.
https://www.cs.umd.edu/~clin/MoreJava/Container/alist-prob-swap.html

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.