Created
June 13, 2015 16:19
-
-
Save AnimeshShaw/4ffa60a27b63560b7a4b to your computer and use it in GitHub Desktop.
JStack Demo Usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.codehackersblog.JStack.JStack; | |
| /** | |
| * | |
| * @author psychocoder | |
| */ | |
| public class JStackDemo { | |
| public static void main(String[] args) { | |
| JStack<String> jstack = new JStack(); | |
| jstack.push("1"); | |
| jstack.push("2"); | |
| jstack.push("3"); | |
| jstack.push("4"); | |
| System.out.println("Print All Elements in Stack : \n"); | |
| for (Object m : jstack.elements()) { | |
| System.out.println(m.toString()); | |
| } | |
| jstack.pop(); | |
| jstack.pop(); | |
| System.out.println("\nAll Elements in Stack are : \n" + jstack.display()); | |
| System.out.println("\nTop Element : " + jstack.peek()); | |
| jstack.push("3"); | |
| jstack.push("4"); | |
| System.out.println("\nSize of Stack : " + jstack.size()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment