fork download
  1. class Example {
  2. private String str;
  3.  
  4. public class Inner {
  5. void show() {
  6. // Show the string for the Example this Inner is part of
  7. System.out.println(Example.this.str);
  8. }
  9. }
  10.  
  11. public Example(String s) {
  12. this.str = s;
  13. }
  14.  
  15. public static void main(String[] args) {
  16. Example e1 = new Example("e1");
  17. Example e2 = new Example("e2");
  18. Inner i1 = e1.new Inner();
  19. i1.show(); // "e1"
  20. Inner i2 = e2.new Inner();
  21. i2.show(); // "e2"
  22. }
  23. }
Success #stdin #stdout 0.06s 32492KB
stdin
Standard input is empty
stdout
e1
e2