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 607655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:22:59+00:00 2026-05-13T17:22:59+00:00

I am adding information from main() I am adding different information for CD, DVD,

  • 0

I am adding information from main()
I am adding different information for CD, DVD, book..

I have 3 separate classes – item has 3 classes in it…

  1. project – main()

  2. Library – this function does all the adding

  3. Item(cd,dvd,book) inheritance

For Music i am adding band info, title info, keywords, and members..
I am adding members separately than of the other info..

As you can see the members is not outputing correctly as the others..

>>> music CDs:

-Music-
band: Jerry Garcia Band
# songs: 15
members: [Ljava.lang.String;@61de33
title: Don't Let Go

C:\Java\a03>

I am using the same toString() function for members as i am the rest, so i am not sure why it would do this..

I will give you as much info as i think you need to see..

Main() – as you can see it calls 2 different functions.

the addbandmembers is where i am having problems…

out.println(">>> adding items to library:\n");
item = library.addMusicCD("Europe In '72", "Grateful Dead", 12, "acid rock", "sixties", "jam bands");
    if (item != null) {
        library.addBandMembers(item, "Jerry Garcia", "Bill Kreutzman", "Keith Godcheaux");
        library.printItem(out, item);
        }

in Library class – here is the addbandmember function ..

Could this be the cause??

public void addBandMembers(Item musicCD, String... members)
{

    ((CD)musicCD).addband(members);

}

In the Items class here is the function addband – tostring()

here is the CD class which extends the items class..

class Item
{
    private String title;

    public String toString()
    {
        String line1 = "title: " + title + "\n";
        return line1;
    }

    public void print()
    {
        System.out.println(toString());
    }

    public Item()
    {}

    public Item(String theTitle)
    {
        title = theTitle;
    }

    public String getTitle()
    {
        return title;
    }
}

class CD extends Item
{
    private String artist;
    private String [] members;
    private int number;

    public CD(String theTitle, String theBand, int Snumber, String... keywords)
    {
        super(theTitle);
        this.artist = theBand;
        this.number = Snumber;
    }

    public void addband(String... member)
    {
        this.members = member;
    }

    public String getArtist()
    {
        return artist;
    }

    public String [] getMembers()
    {
        return members;   
    }

    public String toString()
    {
        return  "-Music-" + "\n" + "band: " + artist + "\n" + "# songs: " + number + "\n" + "members: " + members + "\n"  + "\n" + super.toString() + "\n";
    }

    public void print()
    {
        System.out.println(toString());
    }
}

I do have other information in the items class like a nook class, movie class that i didnt show. I would like to keep everything the way i have it set up..

So, if the other items are printing fine than maybe its the cast in the addbandmember function thats giving me problems?

  • 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-13T17:22:59+00:00Added an answer on May 13, 2026 at 5:22 pm

    Arrays don’t have a useful toString() implementation. You can print out the members in a loop or use the Arrays.toString() method to do this for you:

    return "-Music-" + "\n"
        + "band: " + artist + "\n"
        + "# songs: " + number + "\n"
        + "members: " + Arrays.toString(members) + "\n"
        + "\n"
        + super.toString() + "\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 407k
  • Answers 407k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer To start with, always use ===. That will prevent JavaScript… May 15, 2026 at 6:34 am
  • Editorial Team
    Editorial Team added an answer There's no reason the drawing of a single label should… May 15, 2026 at 6:34 am
  • Editorial Team
    Editorial Team added an answer with json.net you can use the JsonPropertyAttribute to give your… May 15, 2026 at 6:34 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.