- #1

- 2

- 0

## Main Question or Discussion Point

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;
}
}
```

Last edited by a moderator: