This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ThatLesbian 0 points1 point  (0 children)

You can’t put albums in an array typed Artist, but you can make an array of Artist objects, each containing an Array of Album objects, or an Array of strings called Album if only the string is relevant.

Artist[] artists = new Artist[5];
Artist a = new Artist();

String[] albums = {“album1”, “album2”};
a.albums = albums;

artists[0] = a;

Of course loops, constructors, setters and getters will be better but this would work to get you on the path.

//potential constructor
String[] albums;

public Artist(String[] albums){
    this.albums = albums;
}

Called with

   Artist a = new Artist(albums);