Hello, I'm suppose to convert some c code to java code. : I was giving some c code to convert to java code.  implement three different methods of generating all N!
permutations of N elements in Java. The code I provided is my converted c code to java, I was successful up until this line of code, swap((n & 0x01) ? 1 : i, n);...in the permute3 method, Im not entirely sure what it is doing or means and i need to know how to write the equivalent in java.


public class Permute {

	public static final long MILLION = 1000000L;
	
	static int N;
	static char p[];
	static int[][] table =	 { {0}, {0, 1}, {0, 1, 1}, {0, 1, 2, 3},
			      {0, 3, 1, 3, 1},
			      {0, 3, 4, 3, 2, 3},
			      {0, 5, 3, 1, 5, 3, 1},
			      {0, 5, 2, 7, 2, 1, 2, 3},
			      {0, 7, 1, 5, 5, 3, 3, 7, 1},
			      {0, 7, 8, 1, 6, 5, 4, 9, 2, 3},
			      {0, 9, 7, 5, 3, 1, 9, 7, 5, 3, 1},
			      {0, 9, 6, 3, 10, 9, 4, 3, 8, 9, 2, 3}};



	
	public static void init()
	{
	p = new char[27];	
	p[0] = '*';
	
	for(int i = 0; i < 26; i++)
	{
		p[i + 1] = (char) ('A'+i);
	}
	
	
	}

	public static void swap(int i, int j)
	{
		char c;
		
		c = p[i];
		p[i] = p[j];
		p[j] = c;
	}
		
	static void printIt()
	{
		long count = 0;
		
		//to compare performance, comment out from here
		 
		  
		 for (int i = 1; i <= N; i++)
		 System.out.printf("%c", p[i]);
		 System.out.printf("\n");
		 //to here
		  
	    count++;
	
	}
	
	static void permute1(int n)
	{
		if(n == 1)
		{
			printIt();
		}
		
		for(int i = 1; i <= n; i++)
		{
			swap(i, n);
			permute1(n-1);
			swap(i, n);
		}
	}
	
	static void permute2(int n)
	{
		if(n == 1)
		{
			printIt();
			return;
		}
		for(int i = 1; i <= n; i++)
		{
			permute2(n-1);
			swap(table[n][i], n);
			
		}
	}
	
	static void permute3(int n)
	{
		if(n == 1)
		{
			printIt();
			return;
		}
		for(int i = 1; i <= n; i++)
		{
			permute3(n - 1);
			swap((n & 0x01) ? 1 : i, n);
		}
	}


	



	public static void main(String[] args) {
		
		
		/*N = Integer.parseInt(args[0]);
		int alg = Integer.parseInt(args[1]);*/
		
		if(args.length <= 0)
		{
			N = 4;
			int alg = 1;
			init();
			long startTime = System.nanoTime();
			permute1(N);
			long endTime = System.nanoTime();

			float duration = ((endTime - startTime)/ MILLION);
			System.out.printf("permute%1d, N = %d, %f\n",alg, N, duration);
		}
		else
		{
			N = Integer.parseInt(args[0]);
			int alg = Integer.parseInt(args[1]);
			
				switch(alg)
				{
					case 1:
						init();
						long startTime = System.nanoTime();
						permute1(N);
						long endTime = System.nanoTime();
			
						float duration = ((endTime - startTime)/ MILLION);
						System.out.printf("permute%1d, N = %d, %f\n",alg, N, duration);
						break;
						
					case 2:
						init();
						long startTime2 = System.nanoTime();
						permute2(N);
						long endTime2 = System.nanoTime();
			
						float duration2 = (endTime2 - startTime2) / MILLION;
						System.out.printf("permute%1d, N = %d, %f\n",alg, N, duration2);
						break;
						
					case 3:
						init();
						long startTime3 = System.nanoTime();
						permute3(N);
						long endTime3 = System.nanoTime();
			
						float duration3 = (endTime3 - startTime3)/ MILLION;
						System.out.printf("permute%1d, N = %d, %f\n",alg, N, duration3);
						break;
						
					default:
						
						
					}
				
				}
		
		
		
		

	}

}