Tuesday 5 March 2019

java - could not find or load main class error?

I'm getting the error of "Could not find or load main class InsertionSort", I gets InsertionSort.CLASS by javac but could not execute it by java InsertionSort
and java com.assignment.sort.insertionsort.InsertionSort



Code:




   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;
}
}
}

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...