5:30 pm - Sunday August 19, 2018

Stack Example Program for search(Object o)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
*@author :CandidJava.com
*@descriptions : This program explain the function and use of search () .
*/
import java.io.*;
import java.util.*;
public class Search
{
public static void main(String args[])
{
Stack s=new Stack();
s.push(1);
s.push(2);
s.push(3);
s.push(4);
System.out.println(s);
int e=s.search(3);  //  Returns the position of the searched element
System.out.println("Index of searched element is:"+e);
}
}

OUTPUT:
[1, 2, 3, 4]
Index of searched element is:2

BACK

Filed in: Z-A All Java Codes

Comments are closed.