Hi, I'm currently working on my selection sort code, and I've come across some problems.(adsbygoogle = window.adsbygoogle || []).push({});

Can someone please tell me what the problem is?Code (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;

}

}

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Java [Java] Selection Sort

**Physics Forums | Science Articles, Homework Help, Discussion**