hello everyone, I'd like to use vectors in my program instead of arrays because of the advantages of them being dynamic. Here is my question: If I originally had an array of type "typeX" declared as such: typeX array = new typeX; How could I declare a vector of type typeX? I've tried: typeX Vector myVector = new Vector(); but that doesn't seem to work. Any help would be appreciated. Thanks
Couple of things: 1. Use ArrayList instead. Vector basically shouldn't be used anymore. 2. Currently you can't declare an ArrayList to be of a certain type. You can add any Object to an ArrayList, but the drawback is that you usually have to cast them when you retrieve them in order for them to be useful. For example:
There is some kind of an initiative (or JRS or something like that) to add that functionality to the language. Check out this link on generics
Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
hello Malcolm, Blake's right there. On your vector query, a vector object is of type Vector. So your 'typeX Vector myVector = new Vector()' will not work as the objects references contained in the vector object could be of different types. 'Vector myVector = new Vector();' will do. [ February 25, 2003: Message edited by: boyet silverio ] [ February 25, 2003: Message edited by: boyet silverio ]
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com