java - running an algorithm without a Main class? -


i'm learning java introduction java programming 9th ed. liang y. d. , having difficulty 1 of examples, pertaining arrays. execute sorting procedure following:

public class selectionsort  { public static void selectionsort (double[] list) {     (int = 0; < list.length - 1; i++)     {         double currentmin = list[i];         int currentminindex = i;          (int j = + 1; j < list.length; j++)         {             if (currentmin > list[j])             {                 currentmin = list[j];                 currentminindex = i;             }         }          if (currentminindex != i)         {             list[currentminindex] = list[i];             list[i] = currentmin;         }     } } } 

the problem there no

main (string[] args) 

instead have:

selectionsort (double[] list) 

now execute above

double[] list = {1, 9, 4.5, 6.6, 5.7, -4.5}; selectionsort.selectionsort(list) 

or other combintion, keep getting error: not find or load main class. there way execute in command prompt without loading main class?

make main class.

public class arraytest {     public static void main(string[] args) {         double[] list = { };         selectionsort.selectionsort(list);     } } 

note: not this. bad practice , not work in newer versions of java anyways.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -