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. class OnibusBiTrem extends Bus implements IMultiplosVagoes {}
  8. class Bus extends Car{}
  9. class Car implements HasPassengers{}
  10. interface HasPassengers{}
  11. interface IMultiplosVagoes {}
  12. /* Name of the class has to be "Main" only if the class is public. */
  13. class Ideone
  14. {
  15. public static void main (String[] args) throws java.lang.Exception
  16. {
  17. OnibusBiTrem oni = new OnibusBiTrem();
  18. Class<?> classes = oni.getClass();
  19. Set<String> items = new HashSet<>() ;
  20. SetInterfaces(classes, items)
  21. .forEach((item) -> {
  22. System.out.println(item);
  23. });
  24. }
  25. public static Set<String> SetInterfaces(Class<?> aClass,
  26. Set<String> items)
  27. {
  28. for (Class<?> intf : aClass.getInterfaces()) {
  29. items.add(intf.getName());
  30. SetInterfaces(intf, items);
  31. }
  32. if (aClass.isInterface() == false && aClass.getSuperclass() != null) {
  33. SetInterfaces(aClass.getSuperclass(), items);
  34. }
  35. return items;
  36. }
  37. }
Success #stdin #stdout 0.06s 33656KB
stdin
Standard input is empty
stdout
HasPassengers
IMultiplosVagoes