Java Stack: push() and empty() methods
KW.java
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW Blueberry Apple Cherry Grapes Mango Orange Apple kodingwindow@kw:~$
Java Stack: empty() and search() methods
KW.java
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW [Apple, Orange, Mango, Grapes, Cherry, Apple, Blueberry] false 6 1 -1 -1 kodingwindow@kw:~$
Java Stack: peek() and pop() methods
KW.java
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW Peek element: Blueberry Popping: Blueberry Stack elements: Apple Cherry Grapes Mango Orange Apple kodingwindow@kw:~$
Advertisement