aspose file tools
The moose likes Java in General and the fly likes Creating a LinkedList of class objects Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Creating a LinkedList of class objects" Watch "Creating a LinkedList of class objects" New topic
Author

Creating a LinkedList of class objects

Richard Shelly
Greenhorn

Joined: Oct 03, 2005
Posts: 24
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

Joined: Jan 24, 2005
Posts: 489

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

Joined: Oct 03, 2005
Posts: 24
thanks Ram.

the 'names' to which i referred are strings within the defined class. if that changes anything.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Creating a LinkedList of class objects
 
Similar Threads
convert array to Arraylist
Question for Herb (or anyone else) on Generics and unknown object types
how to sort this list ?
Dynamically generated objects
Trying to add Object values to a List, but the last value keeps getting added for all the values