Comment on Tutorial - Stack example in Java - push(), pop(), empty(), search() By Henry
Comment Added by : jack&jill
Comment Added at : 2011-07-26 06:40:32
Comment on Tutorial : Stack example in Java - push(), pop(), empty(), search() By Henry
import java.io.*;
import java.util.Stack;
public class Stacks {
public static void main(String args[])throws IOException {
DataInputStream k=new DataInputStream(System.in);
Stack r=new Stack();
for(int i=1; i<=3; i++) {
System.out.print(" ");
System.out.print("Enter a value to PUSH: ");
int x=Integer.parseInt(k.readLine());
r.push (new Integer(x) );
System.out.print("Stacked: "+r+"\n");
}System.out.println("STACK IS FULL!");
do {
for(int i=1; i<=3; i++) {
System.out.print(" "
);
System.out.print("Enter a value to POP: ");
int x=Integer.parseInt(k.readLine());
r.pop();
System.out.print("Stacked: "+r+"\n");
}
}while(!r.empty());
System.out.println("STACK IS EMPTY!");
}
}
View Tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Java program to get location meta data from an image
Program using concept of byte long short and int in java
Update contents of a file within a jar file
Tomcat and httpd configured in port 8080 and 80
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program in Java
Calculate gross salary in Java
Calculate average sale of the week in Java
Vector in Java - Sample Program
Archived Comments
1. ya its good example
View Tutorial By: vijaychellappa at 2010-11-10 04:57:42
2. i am getting d following error:-
Se
View Tutorial By: nikitha at 2013-02-07 09:23:12
3. Amazing tutorial!! This is what I was exactly look
View Tutorial By: Sumanth Vaidya at 2015-06-17 18:19:16
4. Hey, this is a great explanation regarding the dif
View Tutorial By: foam roofing at 2011-04-02 17:26:52
5. I'm working on an intranet site/web application. W
View Tutorial By: Tony Gingrich at 2011-10-23 21:22:31
6. Good programs example need for me
View Tutorial By: G.Venugopal at 2009-11-11 08:46:38
7. i can saved when i run the program...
but w
View Tutorial By: kathleen ashley at 2010-08-02 05:22:46
8. Thank you very much for such a nice topic
View Tutorial By: CHANDAN at 2012-11-01 04:40:02
9. Hello all,
I need the codes for sen
View Tutorial By: Fionna at 2009-07-13 00:34:45
10. i find out this example quite heplful thnx adimn..
View Tutorial By: ayaz pathan ( MUET) at 2010-02-21 10:40:18