无法找到或加载主类错误?

时间:2015-10-17 10:52:49

标签: java

我收到" 的错误无法找到或加载主类 InsertionSort",我通过javac获取InsertionSort.CLASS但是无法通过 java InsertionSort 执行它 和 java com.assignment.sort.insertionsort.InsertionSort

代码:

   package com.assignment.sort;

   import java.util.Scanner;

   public class InsertionSort
   {
      public static void main(String [] args)
      {
         Scanner input = new Scanner(System.in);
         int [] arr;
         int n;
         System.out.println("ENter no. of elements ");
         n = input.nextInt();
         arr = new int[n];
         sort(arr); 
         for(int i = 0; i< n; i++ )
         {
             System.out.println("elements are " + arr[i] );
         }
    }
    public static void sort(int [] ar)
    {
        int a = 1;
        int temp;
        int ptr = a-1;
        temp = ar[a];
            for(int i = a ; i < ar.length; i++)
            { 
                 temp = ar[a];

                while(temp < ar[ptr] && ptr >= 0)
                {
                    ar[ptr + 1] = ar[ptr];
                    ptr = ptr - 1;
                }
                ar[ptr + 1] = temp;
                ++a;
            }
        }
    }

1 个答案:

答案 0 :(得分:-1)