Selection sort program in java using array

Print the selection sort program in java using array. In Java programming, there is a selection sort program. This selection sort programme is a very advanced sorting program that is also very relevant. It will choose the item and sort the elements. Click here for pattern program in Java

public class Main
{
public static void sorting(int[] arr)
{
for (int i = 0; i < arr.length - 1; i++)
{
int index = i;
for (int j = i + 1; j < arr.length; j++)
{
if (arr[j] < arr[index])
{
index = j;
}
}
int small = arr[index];
arr[index] = arr[i];
arr[i] = small;
}
}
public static void main(String a[])
{
int[] arr1 = {45,56,67,1,34,46,67};
System.out.println("Before Selection sort");
for(int i:arr1){
System.out.print(i+" ");
}
System.out.println();
sorting(arr1);
System.out.println("After Selection sort");
for(int i:arr1){
System.out.print(i+" ");
}
}
}

Output:
Before Selection sort   
45 56 67 1 34 46 67 
After Selection sort 
1 34 45 46 56 67 67