Open In App

What are the negative aspects of Java Stack class inheriting from Vector?

Java Vector:

Vectors are analogous to arrays in a way that both of them are used to store data, but unlike an array, vectors are not homogeneous and don’t have a fixed size. They can be referred to as growable arrays that can alter their size accordingly. It is relatively a memory-efficient way of handling lists whose size could change drastically. 

It is found in “java.util” package and implements the List interface as displayed in the figure below:



List interface used by vector

To learn more about vector class in Java refer to the article “Vector class in Java“.

Stack Class:

A Stack is a data structure where elements can be inserted and deleted from the front end also known as the ‘Top’ of the stack. 



Insertion in Stack is given a standard name Push and deletion is given a standard name Pop. This class can also be referred to as the subclass of Vector. The Stack class in Java is an extension of the “Vector” class.

Negative aspects of Java Stack class inheriting from Vector class:

The negative aspects of the Java Stack class inheriting from the Vector class are mentioned below:

Article Tags :