Vector return type

i have some components in my vector. when i call v.elementAt(3);it returns an object, there is a component in v(3) how can i get a component from vector...thanks for help...
[201 byte] By [aDiGea] at [2007-11-26 19:58:23]
# 1
Which Java version are you using ?If you use at least java 5.0 (Tiger) you can work with Generics and then avoid the need for casting.Otherwise, you have to cast that method return Object.Regards,Sebastien Degardin
sdegardina at 2007-7-9 22:54:04 > top of Java-index,Java Essentials,Java Programming...
# 2

Cast it:

Component myComp = (Component)v.elementAt(3);

You might want an ArrayList instead of a Vector. Or, at least use "get" instead of "elementAt", and use other stuff from the "List" interface if possible, instead of using stuff that's only in Vector. That way, if you change to ArrayList later, the rest doesn't need to change.

doremifasollatidoa at 2007-7-9 22:54:04 > top of Java-index,Java Essentials,Java Programming...
# 3
yes, it works..thanks for advice...
aDiGea at 2007-7-9 22:54:05 > top of Java-index,Java Essentials,Java Programming...