Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class AnyWildCardDemo {
- public static void main(String [] args)
- {
- GenericStack<Integer> intStack = new GenericStack<>();
- intStack.push(1);
- intStack.push(2);
- intStack.push(3);
- print(intStack);
- }
- //<?> is equivalent with <? extends Object>
- public static void print(GenericStack<?> stack)
- {
- while(!stack.isEmpty())
- {
- System.out.print(stack.pop() + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement