- #1

- 2

- 0

Hi, I'm currently working on my selection sort code, and I've come across some problems.

*
*

Can someone please tell me what the problem is?
Java:

```
i
import java.util.Arrays;
import java.io.*;
public class SelectionSort
{
int a[];
static int n;
public static void main(String[] args)
{
int array[] = { 5,3,9,7,1,8 };
n = 6;
System.out.println(""+Arrays.toString(Sort(array)));
}
public static int[] Sort(int[] arr)
{
int t, min;
for(int i=0;i<n-1;i++)
{
min = i;
for(int j=i+1;j<n;j++)
{
if(a[min]>a[j])
min = j;
}
if(min!=i)
{
t = a[min];
a[min] = a;
a = t;
}
System.out.println(""+Arrays.toString(arr));
}
return arr;
}
}
```

Can someone please tell me what the problem is?

Last edited by a moderator: