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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:17:20+00:00 2026-05-27T05:17:20+00:00

I want to build a simple application for a bookstore. There are a few

  • 0

I want to build a simple application for a bookstore. There are a few types of things on sale: books, movies, and magazines. I was thinking to of building one abstract class with a toString() method, and 3 subclasses – books, movies, magazines (there will be more later). Then in the program I want to operate on these objects and was thinking I would keep them all in an ArrayList<ParentClass>. Is this a good choice of data structure?

  • 1 1 Answer
  • 1 View
  • 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-27T05:17:21+00:00Added an answer on May 27, 2026 at 5:17 am

    First, I’d recommend you to use generics. If for example you are going to define abstract class (or probably better interface Item) so create new ArrayList<Item>, so you will not be able to add there anything except Item.

    Second, use interface. You definition should look like:

    List<? extends Item> lll = new ArrayList<Item>();

    The choice of the main data structure depends on your needs. I believe that you are going to perform some kind of search mechanisms. In this case probably you can use Map or combine list where you store all objects sequentially and several maps that help you to perform search by different parameters.

    Anyway you should wrap your data structure by some class (model) that provides basic functionality of your business logic, so if you want to change something you can do it within this class without any changes in other parts of your application.

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

Sidebar

Related Questions

I want to build a simple application with the MVVM pattern. This application will
I want to build a very simple GUI based application in linux, c++. Which
I am a beginner in Android programming. I want to build a simple application
I want to build a simple web-interface application that can send/receive chat messages to/from
I want to build very simple help desk application in purpose of learning grails.
I wish to build a simple application with 3 types of objects: Article (1st
I want to build simple camel application, which will get xml from URL and
I want to build as simple notepad application with some code-completion. It should be
I'm trying to build a simple AWT application in Java. I want all of
I really want to build a web application; something simple, maybe a database of

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.