java implementation of stackby means of generic singly linked listis given in code fragment all the methods of the stack interface are executed in constant time in addition to being time efficientthis linked list implementation has space requirement that is ( )where is the current number of elements in the stack thusthis implementation does not require that new exception be created to handle size overflow problems we use an instance variable top to refer to the head of the list (which points to the null object if the list is emptywhen we push new element on the stackwe simply create new node for ereference from vand insert at the head of the list likewisewhen we pop an element from the stackwe simply remove the node at the head