LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-26-2005, 11:26 PM   #1
dflan98783
LQ Newbie
 
Registered: Oct 2005
Location: Stafford, VA
Posts: 6

Rep: Reputation: 0
Exclamation Sorting Arrays with JBuilder


Its late and I am baffled once more. I am wondering what ever possesed me to take this Java programming course online, but here it is.

The example that was given has a list of 8 numbers (2, 9, 8, 7, 5, 4, 6, 1) and used the maximum number and swapped it to the last position, I need to take the smallest number and place it in the first position.

I thought it would be no problem but I was wrong; I am getting a nosuchmethoderror:main when I attempt to run the program.


package selectionSort;

public class SelectionSort {
/**The method for sorting the numbers*/
public static void selectionSort(double[] list) {
for (int i = list.length-1; i >= 1; i--) {
//Find the minimun in the list [0....i]
double currentMin = list[0];
int currentMinIndex = 0;

for (int j = 1; j >= i; j--){
if (currentMin < list [j]) {
currentMin = list [j];
currentMinIndex = j;
}
}

//Swap list [i] with list [currentMinIndex] if necessary
if (currentMinIndex != i) {
list [currentMinIndex] = list [i];
list [i] = currentMin;
}
}
}
}


I know the error usually indicates that there is a mispelling in the main method, or no main method found. But the public class and public static void statements are exactly as in the book. What am I not getting?

Also, will did give the desired result?


Thanks in advance
 
Old 10-26-2005, 11:37 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Uh ... I don't see any "main()". So if you tried any equivalent of "java SelectionSort" (from the command line, from Jbuilder's "run", or any other method of starting Java with that particiular class) ... you'll get precisely that error!

So where *is* your "main()" supposed to be?
 
Old 10-26-2005, 11:42 PM   #3
dflan98783
LQ Newbie
 
Registered: Oct 2005
Location: Stafford, VA
Posts: 6

Original Poster
Rep: Reputation: 0
The example shown did not have a main() in the listing and from what I was reading, I thought that if you passed the paramenter by writing
selectionSort(double[] list)
you would not need to write main(string[] args)

just as in the example they gave in our book.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble getting JBuilder X to run lordtweety Linux - Software 1 05-01-2004 07:57 AM
JBuilder 9 doesn't startup " *** OpenTool com.borland.jbuilder.JBuilderCore failed " moresun Programming 8 11-15-2003 04:45 PM
jbuilder installation seyl Programming 1 07-06-2002 08:02 AM
jbuilder installation ??? seyl Linux - General 1 07-06-2002 08:01 AM
jbuilder installation seyl Linux - Software 0 07-06-2002 06:32 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration