I have created a Vector which stores random numbers, but I am having trouble retrieving them. How do I retrieve each individual element and print it to a screen?? P.S This vector stores numbers (int) Cheers,Rik
Rik You want to use either get(index) or elementAt(index). Both of them take as an arguemnet the index of the element you want to get. To get all of the elements from a Vector this would do it for you:
This will just use what the default toString() implementation is for whatever object is stored in the Vector. To do something useful just cast it to whatever type of Object it is supposed to be and manipulate it then. hope that helps
You can't store ints in a Vector. You can only store Objects. That might be contributing to your problem..... Also, I would investigate the elements() method in the Vector class. It returns an Enumeration, and you can step through the list nicely. Check out the API for Vector and for Enumeration for the methods.