Results 1 to 5 of 5
  1. #1
    Daggerfang is offline Member
    Join Date
    Oct 2012
    Posts
    7
    Rep Power
    0

    Default I dont know how to fix this error

    Hey guys so I am trying to do a small selection sort method from my textbook, but when I go to run it, I keep getting an error that "main" is not found. When I do place main in my code I get more errors. Here is the code :

    public class sortNumbers {


    public static void main(String[] args) {

    public static void sortNumbers(int[ ] input){
    for (int i = 0; i < input.length - 1; i++) {
    // find the minimum
    int currentMin = input [i];
    int currentMinIndex = i;

    for (int j = i+1; j < input.length ; j++) {
    if (currentMin > input[j]) {
    currentMin = input[j];
    currentMinIndex = j;
    }
    }

    //Swapping Input [i] with input[currentMinIdex]
    if (currentMinIndex !=i){
    input[currentMinIndex] = input[i];
    input[i] = currentMin;
    }
    }
    }

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default Re: I dont know how to fix this error

    Java Code:
    public static void main(String[] args) {
    
    public static void sortNumbers(int[ ] input){
    is not a valid java code! methods in a method?

  3. #3
    Daggerfang is offline Member
    Join Date
    Oct 2012
    Posts
    7
    Rep Power
    0

    Default Re: I dont know how to fix this error

    So how would I fix it so that the array works in the main ?

  4. #4
    Daggerfang is offline Member
    Join Date
    Oct 2012
    Posts
    7
    Rep Power
    0

    Default Re: I dont know how to fix this error

    Nevermind I fixed the issue :P Didn't notice that the brace was in the wrong spot haha

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,244
    Rep Power
    19

    Default Re: I dont know how to fix this error

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Dont know if you have it yet Competitions?
    By CodeMonkeyAlx in forum Suggestions & Feedback
    Replies: 0
    Last Post: 09-06-2012, 08:20 PM
  2. HELP ...DONT UNDERSTAND Error
    By ask4soteria in forum New To Java
    Replies: 6
    Last Post: 11-26-2010, 09:43 AM
  3. Using libraries that others dont have(j3d)
    By scorpion9 in forum Advanced Java
    Replies: 7
    Last Post: 02-19-2010, 11:24 AM
  4. Sometimes get the right results sometimes dont
    By Battlefeldt in forum New To Java
    Replies: 0
    Last Post: 12-18-2009, 01:03 AM
  5. Replies: 3
    Last Post: 05-04-2009, 03:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •