Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class FooTest {
- public static String stuff = "";
- public static void main (String[] args) {
- FooTest t = new FooTest();
- t.go();
- }
- public void go() {
- Foo f1 = new Foo();
- // instance of anon subclass
- Foo f2 = new Foo(){
- public void say () {
- System.out.println("Modded Foo says: " + stuff);
- }
- };
- f1.whichClassAmI();
- f2.whichClassAmI();
- stuff = "stuff";
- f1.say();
- f2.say();
- Foo f3 = f1.getAnotherFoo(); // <-- enclosing class is null
- f3.say();
- Foo f4 = f2.getAnotherFoo(); // <-- works now
- stuff = "cloned stuff";
- f4.say();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement