This tutorial How to create a Stack program in Java is very similar to queue program in java as I already posted in this blog. The Stack has to fuctions, the push and pop, push means insert and pop means remove.
If we compare it to Queue, the elements is inserted at the end of the queue while removing the first element. While the Stack program, the element is inserted and deleted only from the end (top).
The same with Queue, I created this program with two java class for codes and 1 text file for the data. We used File Scanner and String Tokenizer to read and split row data. In my case, I used the following filenames:
Demo_Stack.java
Stack_Book.java
what_Book.txt
If we compare it to Queue, the elements is inserted at the end of the queue while removing the first element. While the Stack program, the element is inserted and deleted only from the end (top).
Image: Incodom |
Demo_Stack.java
Stack_Book.java
what_Book.txt
0 Comments