public E
push(E item)
Pushes
an item onto the top of this stack. Return the item pushed on to the
stack.
import java.util.*; class StackPush{ public static void main(String args[]){ Stack<Integer> myStack = new Stack<> (); /* Add Elements to myStack */ myStack.push(10); myStack.push(20); myStack.push(30); System.out.println("Elements in myStack are"); System.out.println(myStack); } }
Output
Elements in myStack are [10, 20, 30]
No comments:
Post a Comment