I am very much a beginner in programming, so this maybe nothin but this error keeps popping up and i'm unsure why.

cannot find symbol - constructor Track

this is my source code and its a work in progress.

public class Track
{

     private String name;

     private String creator;

     private String type;

     private String number;

     private int length;



    public Track(String trackName, String artistCreator, String genreType, String referenceNumber, int trackLength)
    {

        this.name = trackName;
        this.creator = artistCreator;
        this.type = genreType;
        this.number = referenceNumber;
        this.length = trackLength;
    }


    public String getName()
    {
        return name;
    }


    public String getCreator()
    {
        return creator; 
    }


    public String getType()
    {
        return type;
    }


    public String getNumber()
    {
        return number;
    }


    public void changeNumber(String newReferenceNumber)
    {
        //number = newReferenceNumber;
        int size = newReferenceNumber.length();
        if (size >= 3)
    {
        number = newReferenceNumber;
    }
    else
    {
        System.out.println("------------------------------------------");
        System.out.println("Please enter a three digit number.");
        System.out.println("------------------------------------------");
    }
    }   


    public int getLength()
    {
        return length;
    }


    public void viewTrack()
    {

        System.out.println("------------------------------------------");
        System.out.println(" " +"Track name:" +"           " +  name);
        System.out.println(" " +"Artist name:"+ "          " +  creator);
        System.out.println(" " +"Genre:"+ "                " +  type);
        System.out.println(" " +"Length:"+"               " +  length); 
        System.out.println(" " +"Reference Number:"+"     " +  number);
        System.out.println("------------------------------------------");
    }

}


public class Playlist 
{
    private ArrayList<Track> tracks;
    private int nextTrackNumber;


     public Playlist()
    {
       tracks = new ArrayList<Track>();
       nextTrackNumber = 1;

    }

     public Track addTrack()
    {
        tracks.add(new Track());
    }


    public int numberOfTracks()
    {
        return tracks.size();
    }

tracks.add(new Track()); looks for the constructor Track() but you didn't define one, just one with a whole string of parameters

where abouts do i define the parameters?

it doesn't seem like you get it. new Track() is trying to find the default constuctor for "Track" i.e. with no parameters. The only constructor you have defined has many constructors, where you should use new Track(param1, param2, ...).

next time use code tags too

To put some more light onto this:

What James and sillyboy are mentioning that when you say new Track();, the compiler looks for a default constructor, which means constructor with no parameters. But if you check your code you haven't defined any such constructor. The only constructor you have defined is the constructor that receives a whole list of params. What you need to do is put in a constructor/method like this:

public Track(){
    // the way you want the default construction of the object.
}

Now you might be getting confused why you are needing to provide such a type of constructor when you have written programs when you did not write such a constructor. The reason is again the constructor that you provide. What happens is when you do not provide a constructor Java by itself provides the default constructor also called the no-args constructor. But when you do provide a parametrized constructor then you yourself also would have to provide the default constructor ( that is if you want to allow the construction of your objects that way too) Java will not provide the default constructor in this case becuase when you provide a parameterized constructor, but not a default one, it assumes that you know what you are doing and if you aren't providing a default constructor that the way you want it. It assumes that you do not want your objects to initialized in that way.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.