Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. public class AnyWildCardDemo {
  2. public static void main(String [] args)
  3. {
  4. GenericStack<Integer> intStack = new GenericStack<>();
  5. intStack.push(1);
  6. intStack.push(2);
  7. intStack.push(3);
  8. print(intStack);
  9. }
  10. //<?> is equivalent with <? extends Object>
  11.  
  12. public static void print(GenericStack<?> stack)
  13. {
  14. while(!stack.isEmpty())
  15. {
  16. System.out.print(stack.pop() + " ");
  17. }
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement