Stack
Stack
*;
import java.util.*;
class Test
{
// Pushing element on the top of the stack
static void stack_push(Stack<Integer> stack)
{
for(int i = 0; i < 5; i++)
{
stack.push(i);
}
}
if(pos == -1)
System.out.println("Element not found");
else
System.out.println("Element is found at position: " + pos);
}
stack_push(stack);
stack_pop(stack);
stack_push(stack);
stack_peek(stack);
stack_search(stack, 2);
stack_search(stack, 6);
}
}
import java.io.*;
import java.util.*;
class StackDemo {
// Main Method
public static void main(String[] args)
{
// Initialization of Stack
// using Generics
Stack<String> stack2 = new Stack<String>();
stack2.push("Geeks");
stack2.push("For");
stack2.push("Geeks");
import java.util.*;
import java.io.*;