Hi,

I am working on assignments that deal with Generics in java. I have a class Movie that have a String name variable. However I have to add a few more properties to Movie objects like Release year and Director name.

So I created an Inventory class that uses the Movie class objects. Then I created a sub-class ExtendedMovie within the Inventory class which needs a Movie object (string which is a movie name), and it also need a int year and String DirectorName.

Now I am using ArrayList<ExtendedMovie> to build the inventory. My question is, how do I access the movie name, which is in inventory of ExtendedMovie which is a Movie object?

Thanks.

If ExtendedMovie extends Movie then you can access the name via the inherited accessor methods of the Movie class

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.