title: What is wrong with my selection sort algorithm?
body: <p>I am making a selection sort algorithm in Java.</p>
  
  <p>The logic seems to be perfect, but this code is not sorting the elements. </p>
  
  <pre><code>import java.util.Arrays;
  public class selectionsort{
  
      int y;
  
  
      void swap(int a[], int firstindex, int secondindex){
          int temp=a[firstindex];
          a[firstindex]=a[secondindex];
          a[secondindex]=temp;
  
      }
  
      public void selectionsort1(int a[],int i){
         int lowestindex;
         for(y=0;y&lt;a.length-2;y++){
             lowestindex=selectionsort2(a,y);
             swap(a,y,lowestindex);
         }
  
      }
  
      public int selectionsort2(int a[],int y){
          int setvalue=a[y];
          int setindex=y;
          for(int x=setindex+1;x&lt;a.length;x++){
              if(a[x]&lt;setvalue){
                  setvalue=a[x];
  
              }
  
          }
          return setvalue;
      }
  
      public static void main(String args[]){
          int[] a={88,28,39,40,15,06,97,80};
          int i=0;
          int y=0;
          selectionsort s1=new selectionsort();
          s1.selectionsort1( a, i);
          for (int element: a) {
              System.out.println(element);
          }
      }
  
  
  }
  </code></pre>
  
  <p>Why doesn't this work?</p>