Comment on Tutorial - Stack example in Java - push(), pop(), empty(), search() By Henry

Comment Added by : srikanth

Comment Added at : 2014-05-30 06:44:58

Comment on Tutorial : Stack example in Java - push(), pop(), empty(), search() By Henry
import java.util.*;
class Stackdemo
public static void main(String []args)throws IOException
Stack<Integer> st=new Stack<>();
Buffer Reader br =new Buffer Reader(new InputStreamReader(;
int element,pos,choice=0;
System.out.println("stack operation");
System.out.println("1 push element");
System.out.println("2 pop element");
System.out.println("3 search for element");
System.out.println("4 exit");
System.out.println("your choice");
System.out.print("enter element:");
element =Integer.parseInt(br.readline());
Integer i=st.pop();
System.out.print("enter element");
System.out.println("element not found");
System.out.println("element found position:"+pos);


View Tutorial

Ask a Question

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

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions 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

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. What if I wanted POST instead of GET?
View Tutorial          By: Otto at 2011-06-12 15:38:50

2. It tried this app... It's working fine... really a
View Tutorial          By: Prakash at 2012-01-04 06:33:12

3. help me in my final project about arrays
View Tutorial          By: grace at 2013-03-13 09:54:11

4. how to java program run in system and how to open
View Tutorial          By: safeek at 2012-10-20 06:54:38

5. hi

im trying to run this project an

View Tutorial          By: VoyRufino at 2010-01-26 10:03:11

6. Its really helpfull to me thanks................
View Tutorial          By: AKS at 2013-08-10 06:27:43

7. Sir. Please give an example which is small and und
View Tutorial          By: Rafik at 2011-08-17 19:45:04

8. Hi I am new to struts framework. Can u tell how to
View Tutorial          By: Nithya at 2012-11-27 14:03:46

9. the example program is very simple to understand a
View Tutorial          By: Zubilu at 2010-10-06 00:19:13

10. Very Nice and Perfectly Understandable.....
View Tutorial          By: rex at 2015-04-16 12:27:03