fork download
  1. class Ideone {
  2. public static void main(String[] args) {
  3. FooExtends1 foo1 = new FooExtends1();
  4. changeName(foo1);
  5. System.out.println(foo1.getName());
  6.  
  7. FooExtends2 foo2 = new FooExtends2();
  8. changeName(foo2);
  9. System.out.println(foo2.getName());
  10.  
  11. FooExtends3 foo3 = new FooExtends3();
  12. changeName(foo3);
  13. System.out.println(foo3.getName());
  14. }
  15.  
  16. public static void changeName(Foo param1) {
  17. param1.setName("foo");
  18. }
  19. }
  20.  
  21. class Foo {
  22. private String name;
  23.  
  24. public void setName(String name) {
  25. this.name = name;
  26. }
  27.  
  28. public String getName() {
  29. return name;
  30. }
  31. }
  32.  
  33. class FooExtends1 extends Foo {}
  34. class FooExtends2 extends Foo {}
  35. class FooExtends3 extends Foo {}
Success #stdin #stdout 0.06s 32392KB
stdin
Standard input is empty
stdout
foo
foo
foo