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

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. Wow, incredible code!! With some brains this is a
View Tutorial          By: Dem0-n at 2011-06-11 07:10:12

2. Many thanks for your nice explanation.
View Tutorial          By: Zahra at 2012-04-10 06:03:56

3. I wanna to name ,subject and marks of every subjec
View Tutorial          By: raveesh yadav at 2012-10-13 19:56:47

4. why return&else statment repeating?
View Tutorial          By: sudhar at 2012-07-12 14:50:45

5. Many many thanks. It is very very helpful. Again t
View Tutorial          By: Mehedi Hasan at 2009-09-15 21:41:51

6. Clear explaination..Thank You Sir...
View Tutorial          By: nishanth at 2014-06-16 08:58:04

7. but it will be very simple if we use pointer in it
View Tutorial          By: Hot Water Systems at 2009-06-01 03:51:48

8. Hi, You need to place a control on your form

View Tutorial          By: Ranjit at 2010-02-09 02:29:40

9. any one can send serial port communication using n
View Tutorial          By: prakash at 2013-07-01 15:44:48

10. Thank u very much, your topic is very clear, to th
View Tutorial          By: Ahmed Samir at 2011-05-26 23:35:22