What is wrong in this code?

package arrays;

import java.util.Scanner;

public class arraysselectionsort {

public static void main(String[] args) {
	Scanner scn=new Scanner(System.in);
	int n= scn.nextInt();
	int [] arr =new int[n];
	for (int i=0;i<n;i++) {
		arr[i]=scn.nextInt();
	}
	selectionsort(arr);
	display(arr);

}
public static void selectionsort(int [] arr) {
	for (int counter=0;counter <arr.length-1;counter++) {
		int min=counter;
		for (int j=0;j <=arr.length-1;j++) {
			if (arr[j]<arr[min]) {
				min=j;
			}
		}
		int temp= arr[min];
		arr[min]=arr[counter];
		arr[counter]=temp;
	}
}
public static void display(int [] arr) {
	for(int i=0;i<arr.length;i++) {
		System.out.println(arr[i]);
	}
}

}

Hey @harsh.hj
just a change
IN inner for lopp :
for (int j = counter; j <= arr.length - 1; j++) instead of for (int j = 0; j <= arr.length - 1; j++)
correct code :
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = scn.nextInt();
}
selectionsort(arr);
display(arr);
}

public static void selectionsort(int[] arr) {
	for (int counter = 0; counter < arr.length - 1; counter++) {
		int min = counter;
		for (int j = counter; j <= arr.length - 1; j++) {
			if (arr[j] < arr[min]) {
				min = j;
			}
		}
		int temp = arr[min];
		arr[min] = arr[counter];
		arr[counter] = temp;
	}
}

public static void display(int[] arr) {
	for (int i = 0; i < arr.length; i++) {
		System.out.println(arr[i]);
	}
}

}