fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone {
  9. static class First { public void doSmth() { System.out.println("First"); } }
  10. static class Second { public void doSmth() { System.out.println("Second"); } }
  11.  
  12. static interface DoSmth { void doSmth(); }
  13. static class FirstWrapper extends First implements DoSmth {}
  14. static class SecondWrapper extends Second implements DoSmth {}
  15.  
  16. public static void main(String[] args) throws java.lang.Exception {
  17. doSmth(new FirstWrapper());
  18. doSmth(new SecondWrapper());
  19. }
  20.  
  21. public static void doSmth(DoSmth smth) {
  22. smth.doSmth();
  23. }
  24. }
Success #stdin #stdout 0.08s 2841600KB
stdin
Standard input is empty
stdout
First
Second