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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:18:51+00:00 2026-05-11T08:18:51+00:00

Basically I have a custom List class that contains different fruits. Assume that each

  • 0

Basically I have a custom List class that contains different fruits. Assume that each fruit has an ID number that is stored in the list.

Is it better to have:

new AppleList(); new OrangeList(); new LemonList(); 

or

new FruitList<Fruit.Apple>(); new FruitList<Fruit.Orange>(); new FruitList<Fruit.Lemon>(); 

Things to consider:

  • All IDs are of type int.
  • The type of the fruit will not affect the implementation of the List itself. It will only be used by the client of the list, like an external method, etc.

I would like to use the one that is clearer, better in design, faster, more efficient, etc. Additionally if these above 2 techniques are not the best, please suggest your ideas.

EDIT: Btw Fruit is an enum if that wasn’t clear.

  • 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. 2026-05-11T08:18:51+00:00Added an answer on May 11, 2026 at 8:18 am

    •All IDs are of type int.

    •The type of the fruit will not affect the implementation of the List itself. It will only be used by the client of the list, like an external method, etc.

    Given these two facts, I wouldn’t bother with generics. I would put a normal property on FruitList to indicate which type of fruit it is.

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

Sidebar

Related Questions

Basically, I have created a custom control that uses an UpdatePanel, and as I
I have a .NET assembly(3.5 framework) and it basically has a set of custom
I have a list that uses a itemRendererFunction to get custom item renderers. Is
I have a custom ListView that uses a custom ArrayAdapter (which basically just overrides
I have 2 Lists containing entries of a custom class I have created. Basically,
I have created a custom listview that is populated using a row.xml file. Each
I have a DLL assembly that returns a List(of EmailItem). EmailItem is a custom
I have a custom server control which wraps a RadEditor (basically a textarea). I
I have a custom usercontrol, which is basically a dropdownlist, prepopulated with values from
I have a custom component called ButtonPanel written in Actionscript. Basically it's just a

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.