Stack s=new Stack();
Creates an empty Stack Object.
Object push(Object o);
Object pop();
Object peek();
int search(Object o);
importjava.util.*; classStackDemo { public static void main(String args[]) { Stack s=new Stack(); s.push("silan"); s.push("tilan"); s.push("tapu"); System.out.println(s); System.out.println(s.search("silan")); System.out.println(s.search("kahnu")); } }
Output:
[silan,tilan,tapu]
3
-1
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc