Guest User

Untitled

a guest
Jun 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. interface ILeft {}
  2. interface IRight {}
  3.  
  4. class BaseClass implements ILeft {}
  5.  
  6. class WillieClass extends BaseClass implements IRight {}
  7. class WonkaClass extends BaseClass implements IRight {}
  8.  
  9. public class TCall
  10. {
  11. <T extends ILeft & IRight> void foo(T t) {}
  12.  
  13. void bar()
  14. {
  15. foo(new WillieClass());
  16. foo(new WonkaClass());
  17. }
  18.  
  19. void quux(Object o)
  20. {
  21. if (o instanceof IRight && o instanceof ILeft)
  22. foo(o); // Can this compile?
  23. }
  24. }
Add Comment
Please, Sign In to add comment