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
Subscribe to Tutorials
Related Tutorials
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
MultiLevel Inheritance sample in Java
Archived Comments
1. Your Work is Good, But i want to ask if there is a
View Tutorial By: Good Muyis at 2011-01-08 09:47:14
2. hi,
i am trying to run this SMS jav
View Tutorial By: Raghavendra at 2010-12-29 08:27:02
3. Hi,
Its good but you can make it more bette
View Tutorial By: vishakha sharma at 2010-12-15 06:14:52
4. thanks a lot
View Tutorial By: Uzzal biswas at 2014-11-04 02:42:54
5. The Compleate Reference
JAVA Seventh Editi
View Tutorial By: joshap at 2014-10-25 12:05:41
6. After coming to second page again I want to go to
View Tutorial By: Bhagi at 2012-09-23 06:25:54
7. I have a computer science lab final on tuesday (09
View Tutorial By: kudas at 2009-06-07 10:55:06
8. EJB's can be deployed on multiple servers and when
View Tutorial By: Tomek at 2011-09-12 12:29:07
9. Hi Friends.... This code is working correctly with
View Tutorial By: kasi at 2009-11-25 23:52:56
10. error :
Object reference not set to
View Tutorial By: Ramnath at 2011-05-30 04:01:32