58.4k views
2 votes
Assume v is a vector of integers that has been declared and initialized. Write a statement that adds the value 42 to the vector.

1 Answer

3 votes

Answer:

v.add(42);

Step-by-step explanation:

A vector is an inbuilt class in Java, which extends AbstractList class of Java. It is a kind of dynamically allocated arrays which does not need size at the time of declaration. It can expand as much as it can. AbstractList class implements the List interface of Java which has some generic functions like add(), sort(), etc.

User Ittupelo
by
5.7k points