fork download
  1. interface Hello {
  2. void hello();
  3. }
  4.  
  5. class World implements Hello {
  6. public void hello() { System.out.println("Hello, World!"); }
  7. }
  8.  
  9. class Greeter implements Hello {
  10. private String name;
  11.  
  12. Greeter(String name) { this.name = name; }
  13.  
  14. public void hello() { System.out.println("Hello," + this.name + "!"); }
  15. }
  16.  
  17. class Main {
  18. public static void main(String[] args) {
  19. Hello world = new World();
  20. Hello greeter = new Greeter("Programowanie Obiektowe");
  21.  
  22. world.hello();
  23. greeter.hello();
  24. }
  25. }
Success #stdin #stdout 0.08s 2184192KB
stdin
Standard input is empty
stdout
Hello, World!
Hello,Programowanie Obiektowe!