sample code todemonstrate stack class
package collection;
import java.util.Stack;
public class StackDemo {
public static void main(String arg[])
{
Stack s=new Stack();
s.push("a");
s.push("b");
s.push("c");
System.out.println(s); // [a,b,c]
System.out.println(s.search("c")); // 1
System.out.println(s.search("a")); // 3
}
}
output:
[a, b, c]
1
3
0 comments:
Post a Comment