• Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating a LinkedList of class objects  RSS feed

 
Richard Shelly
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
im trying to create a linked list of objects that are instantiated from a class i have written.

i was wondering how to make the list of a specific type.

also, i have to create a way of naming each object in the list. by this i mean i have to create an object, it needs to have a name automatically generated (there are rules about the naming.), how can i do this?

the names are an alternation sequense of chars, and digits. e.g A1, A2B4, A2D4F5.

hope this makes enough sense.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All collections allow you to hold any kind of objects. This is true for LinkedLists too.

If you use java 5, you could specify that your collection would hold Objects of only a certain type. If you user defined class is, say, MyClass, then



would ensure that the list would accept objects of type MyClass only.

Its not possible, as far as I know, to dynamically assign names to the reference variables of the Objects of your class.

cheers,
ram.
 
Richard Shelly
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Ram.

the 'names' to which i referred are strings within the defined class. if that changes anything.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!