Hey guys, I recently had an assignment to write a sort algorithm we have not yet gone over in class.
I had no problem getting my code written and to compile, but now that it compiles I keep getting an error that says

"Exception in thread "main" java.lang.NoSuchMethodError: main"

I figured their is an issue with my main section of code but I cannot figure it out, if anyone could help, thanks in advance.

public class shell
{
public shell(int[] anArray)
{
   a = anArray;
}

public void sort()
{
   int increment = a.length / 3 + 1;

   while ( increment > 1 )
   {
      for ( int start = 0; start < increment; start++ )
         insertSort( start, increment );

      increment = increment / 3 + 1;
   } 


   insertSort( 0, 1 );
}

public void insertSort( int start, int increment )
{
   int j, k, temp;

   for ( int i = start + increment; i < a.length; i += increment )
   {
      j = i;
      k = j - increment;
      if ( a[j] < a[k] )
      {

         temp = a[j];
         do
         {
            a[j] = a[k];
            j = k;
            k = j - increment;
         } while ( j != start && a[k] > temp );
         a[j] = temp;
      }
   }
}

private int[] a;
}

Edited 4 Years Ago by Ezzaral: Fixed code fomatting

Sorry I messed up the code

Edited 4 Years Ago by MrHardRock: Messed up the Code

Your class needs a main() method defined if you are going to run it directly.

public static void main(String[] args){
    ...
}

Edited 4 Years Ago by Ezzaral: ...

This article has been dead for over six months. Start a new discussion instead.