I am trying to making Selectionsort but it will give an error
you make a swap, you print out a number. But in an array of 10 elements, you'll
only make 9 swaps -- the final element will already be in its correct place! To
fix this, add
to the end of your function.
the minimum element happens to be
, then no
swap will be performed and no element printed. This still sorts the array, but
if you want it to be printed out, you could remove the
and simply do a swap on every pass through the list.
also take a look at using
s rather than
is generally slower than an
and you usually only use them when Java wants an object.