In my code of selection sort i am not able to get return value from selection sort function which i hane to pass in display function

how to takes return sorted array from selection sort function

package function1;

import java.util.Scanner;

public class Chalengeofselectionsort {
static Scanner scn = new Scanner(System.in);

public static void main(String[] args) {
	int[] array = takesinput();
	int[] sorted = selectionsort(array);
	display(sorted);
}

// takes input function
public static int[] takesinput() {
	//System.out.println("enter the size of array");
	int n = scn.nextInt();
	int[] arr = new int[n];
	for (int i = 0; i < arr.length; i++) {
		//System.out.println("enter the value for" + i + "index");
		arr[i] = scn.nextInt();

	}
	return arr;

}

// selectionsort function
public static int[] selectionsort(int[] array) {
	for (int counter = 0; counter < array.length - 1; counter++) {
		int min = counter;
		for (int j = counter + 1; j < array.length - 1; j++) {
			if (array[j] < array[min]) {
				min = j;

			}
			int temp = array[min];
			array[min] = array[j];
			array[j] = temp;

		}
		
		
	}
	return array;
	

}

//display function
public static void display(int [] sorted) {
for(int i =0; i<sorted.length;i++) {
System.out.println(sorted[i]);
}
}
}
package function1;

import java.util.Scanner;

public class Chalengeofselectionsort {
static Scanner scn = new Scanner(System.in);

public static void main(String[] args) {
	int[] array = takesinput();
	int[] sorted = selectionsort(array);
	display(sorted);
}

// takes input function
public static int[] takesinput() {
	//System.out.println("enter the size of array");
	int n = scn.nextInt();
	int[] arr = new int[n];
	for (int i = 0; i < arr.length; i++) {
		//System.out.println("enter the value for" + i + "index");
		arr[i] = scn.nextInt();

	}
	return arr;

}

// selectionsort function
public static int[] selectionsort(int[] array) {
	for (int counter = 0; counter < array.length - 1; counter++) {
		int min = counter;
		for (int j = counter + 1; j < array.length - 1; j++) {
			if (array[j] < array[min]) {
				min = j;

			}
			int temp = array[min];
			array[min] = array[j];
			array[j] = temp;

		}
		
		
	}
	return array;
	

}

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

Does it show compile or runtime error ?

Sorting ho hi nhi paa raha hai

Error nhi hai kuch vv array hi print ho jaa raha hai sorting nhi ho pa raha hai

Your code for selection sort is wrong.

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.