Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. class Foo {
  2. protected String x = "x";
  3.  
  4. public function getX() {
  5. return x;
  6. }
  7. }
  8.  
  9. class Bar {
  10. protected Foo foo;
  11.  
  12. public Bar() {
  13. this.foo = new Foo();
  14. }
  15.  
  16. public Foo getFoo() {
  17. return foo;
  18. }
  19. }
  20.  
  21. public static void main(String [] args) {
  22. Bar bar = new Bar();
  23. String x = bar.getFoo().getX();
  24. }
  25.  
  26. class Bar {
  27. protected Foo foo;
  28.  
  29. public Bar() {
  30. this.foo = new Foo()
  31. }
  32.  
  33. public String getFooX {
  34. return foo.getX();
  35. }
  36. }
  37.  
  38. public static void main(String [] args) {
  39. Bar bar = new Bar();
  40. String x = bar.getFooX();
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement