Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6529181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:36:21+00:00 2026-05-25T09:36:21+00:00

Ive been trying to work this out for a few hours now, but am

  • 0

Ive been trying to work this out for a few hours now, but am stuck, hence I am coming here for some help.
N.B. I am using BlueJ, to construct these classes, as im still learning.

What I am trying to do is create a PlayList which has a two parameters: name and a ArrayList of tracks.
It then creates a playlist and copies the tracks from the list (in order) onto the playlist; but I dont want any help with this part, as of yet.

My issue is I am unsure how to call the ArrayList when constructing the PlayList.. Because the specified type is of .

public class PlayList
{    
private String myName;
private ArrayList<Track> myTracks;
private int myDuration;

public PlayList(String name, ArrayList<Track> tracks) {
    name = myName;
    myTracks = new ArrayList<Track>();
    for (Track t : tracks) {
        myTracks.add(t);
    }
}

}

What happens, in BlueJ, is when I construct a new PlayList class, it provides an empty field box for String name, and for ArrayList tracks. String name is fine, as I can simply put “anything” but am stuck as to the ArrayList tracks?

I know this is probably isnt a very specific question, but I am still learning.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:36:22+00:00Added an answer on May 25, 2026 at 9:36 am

    The constructor of your PlayList wants an object of type ArrayList filled with elements of type Track. So to create a PlayList you must provide an already created one.

    It depends on your surrounding of the call, maybe you already build a list there and can just put it into your PlayList constructor, but you need something like this anywhere:

    // Create an empty list
    ArrayList<Track> tracks = new ArrayList<Track>();
    // Add a track. e.g. when receiving a gui event
    tracks.add(track); // track was created with new Track()
    

    Or maybe you don’t need/want lists outside of PlayList objects. You could use PlayList objects to manage and encapsulate those, by changing the constructor to only create an empty list on its own and allow others to add tracks to it via an addTrack method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to get this code to work for a few hours now
I've been trying to figure this out for the past few hours and can't
I am trying to work out some performance problems with some JavaScript I've been
I've been pulling my hair out for the last few hours trying to wrestle
I've been trying to get this module to work and no matter what I've
I've been trying to make this calendar_date_picker to work for more than two days,
I've been trying to work out the 'best practices' way to manage file uploads
I've been trying to work out how to implement Church-encoded data types in Scala.
I've been trying to figure out an efficient way to work without reading twice
I've been trying to troubleshoot this, but can't find a good function that will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.