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

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.