mehmet canayaz said:
how can I create a vector with size of 10 which
saves only int values??
how can I specify that the vector will only have int values??
If you're using Java 1.5, you can use generics to accomplish this. If
you're using an earlier version of Java, you can't.
The syntax looks like this:
Vector<Integer> myVectorOfInts = new Vector<Integer>(10);
Note that actually, the vector is specified to only contain Integer
objects (or subclasses of Integer). You can't actually put primitive types,
such as "int" in a Vector. Trying to do so will result in boxing and
unboxing, where the int will automatically get converted to an Integer as
needed.
- Oliver