import java.util.*;

public class SelectSort
{
    // instance variables - replace the example below with your own
    public int x;
    public ArrayList<Integer> a;
    public int n;
    
    public SelectSort(int b)
    {
        a = new ArrayList<Integer>() ; 
        n = a.size();
        for(int i = 1; i < n; i++)
        {
            SortNow(); //tried everything and the call isn't working

            
        }
    }
    
    private int SortNow(int[] a,int i, int n)
    {
        int small = i;
        for(int j = i; i < n; i++)
        {
            if(a[j] < a[small])
            {
                small = j;
            }
        }
        return small;
    }
}

//I know this looks simple but I'm a beginner :).

Edited 5 Years Ago by peter_budo: Keep It Clear - Use code tags

1) Use code Tags
2)SortNow(); // No paramater
3)private int SortNow(int[] a,int i, int n) // Three Paramter

You are calling a function which dont exist...
Pass paramters or make empty paramter function.

public class SelectSort
{
    // instance variables - replace the example below with your own
    public int x;
    public ArrayList<Integer> a;
    public int n;
    
    public SelectSort(int b)
    {
        a = new ArrayList<Integer>() ; 
        n = a.size();
        for(int i = 1; i < n; i++)
        {
            SortNow(int[] w, int n); // says '.Class' expected.
            //Know I stupid but I'm new at this
        }
    }
    
    public int SortNow(int[] a,int i)
    {
        int small = i;
        for(int j = i; i < n; i++)
        {
            if(a[j] < a[small])
            {
                small = j;
            }
        }
        return small;
    }
}
//Don't know what to do

Edited 5 Years Ago by peter_budo: Keep It Clear - Use code tags

1) Use Code Tags [code] Code here [/code]

2) for(int i = 1; i < n; i++)
{
SortNow(int[] w, int n); 
} 
// dont u know how to pass paramter to function

3) Have u imported java.util.ArrayList; for Array List

4) We all make blunder's when we try new things, it isnt stupidity, that what call learning , but before starting try to read books so you can fully use your brain cells at time of coding.

Edited 5 Years Ago by peter_budo: Edited point 1, to show how code tags use should look like

I already imported arraylist. Thing is sometimes I'm good at this but sometimes I'm absolute rubbish (and this is one of those times.), and you are right my brain cells at this time are dead.

Very simple solution, get an IDE that error checks. I recommend Eclipse or NetBeans. I personally use Eclipse and threw your code into a new class and it found several errors that have not yet been addressed.

Also one error that eclipse will not catch because it cannot catch Intention errors nor fallacies:

SortNow(int[] w, int n); // several errors, I'll let Eclipse and Google explain them to you.

//Intention error located in piece below, started in the line above

public int SortNow(int[] a,int i) // i initialized to global n
    {
        int small = i; // small initialized to i which = n
        for(int j = i; i < n; i++) // j initialized to i which = n, i = n therefore i will never be < n, newly initialized j ignored and not incremented nor compared to anything so it will always = n
        {
            if(a[j] < a[small]) // never true... j will always = n = small
            {
                small = j; // they already equal one another so...
            }
        }
        return small; // you basically returned n...
    }

Edited 5 Years Ago by Arrorn: n/a

Thanks a lot :), I actually re-wrote the code and worked on it all day. It works better now but I still have a lot to add to it. Thanks for your advice, I'm using BlueJ :P not really the best in the world but sort of forced to use it. Thanks for point out all the mistakes as well :D. I'm a silly programmer hopefully I get better at code :).

This article has been dead for over six months. Start a new discussion instead.