What is wrong in this code?

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();
}
insertionsort(arr);
display(arr);

}
public static void insertionsort(int [] arr) {
	for(int counter=1;counter<=arr.length-1;counter++) {
		int val= arr[counter];
		int j=counter-1;
		while(j>=0 && arr[j]>val) {
			arr[j+1]=arr[j];
			j--;
		}
		arr[j+1]=val;
		
	}
	
}
public static void display(int [] arr) {
	for(int i=0;i<=arr.length-1;i++) {
		System.out.println(arr[i]);
	}
}

@harsh.hj checking it!

@harsh.hj bro don’t you run the code for sample and check the output? you are printing the numbers in new line and in question its clear that you have to print them space separated.
I have corrected ya code.
Also do mark the doubt resolved and rate!
import java.util.*;
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();
	}
	insertionsort(arr);
	display(arr);
	
	

}
public static void insertionsort(int [] arr) {
	for(int counter=1;counter<=arr.length-1;counter++) {
		int val= arr[counter];
		int j=counter-1;
		while(j>=0 && arr[j]>val) {
			arr[j+1]=arr[j];
			j--;
		}
		arr[j+1]=val;
		
	}
	
}
public static void display(int [] arr) {
	for(int i=0;i<=arr.length-1;i++) {
		System.out.print(arr[i]+" ");
	}
	System.out.println();
}

}