i recently started learning Java. I was studying Vectors and I came across various methods of declaring a Vector
Vector( )
Vector(int size)
Vector(int size, int incr)
Vector(Collection c)
I was able to understand the first two types but was not able to understand the increment type in 3rd type and what and when to use 4th type.
plz explain.
You should use Vector(int size, int incr) when you want to control, what size for Vector will be set after it overflows.
You should use Vector(Collection c) when you want to fill it with values from another Collection.
Follow this link for further information.
Please note that in the most cases you should use ArrayList, not Vector. Vector has its method synchronized, you won't need that always.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With