Saturday, June 13, 2015

Java Code to implement a Stack using Java Generics


In this post I have implemented Stack using Java Generics and the LinkedList class. This post isn't a tutorial rather an implementation of Stack Data Structure.

Code for Stack Interface : StackInterface.java



Code for Stack Interface : JStack.java


Demo Run of Above Implementation

Output


Print All Elements in Stack : 

4
3
2
1

All Elements in Stack are : 
2 1 

Top Element : 2

Size of Stack : 4

0 comments :

Post a Comment

Follow Me!

Blog Archive

Followers

Visitor Map