+ 1

Data structure. Vector

Can I add more than one type in same vector. Java ???

5th Feb 2018, 2:11 PM
Sam Som
Sam Som - avatar
1 Answer
0
yes! It is only if the type which you are adding is subtype of vector type. Let's take a class `Number` it is super class of `Integer` and `Double`. so if you were to create a vector with `Number` as it's type then, each element in that vector is a `Number` or subtype of `Number`. Note: Sub class can be assigned to super class' instance
6th Feb 2018, 1:45 PM
Eboona
Eboona - avatar