Is there any possible way to allow multiple different types of identifiers on a class.

I.e. on ArrayLists you can do:
private ArrayList<Employees> e = new ArrayList<Employees>();

the "Employees" is the identifier and can be accepted along with many others. But if I've created my own class and I want it to be able to accept identifiers, is it possible to do so?

Recommended Answers

Yes, absolutely. And they can be very useful too.
Those things are called "Types", and the whole topic is called "Generics"

Here's the tutorial:

Jump to Post

All 2 Replies

to add an object to (for instance)
ArrayList<YourType> list = new ArrayList<YourType>();

the object you want to add has to pass the "is-a-YourType"
it's not that difficult to do that, but the compiler will not allow any that don't pass this test to be added, so reading up on Generics is indeed a good way to start.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.