In Java, what is the difference between this.method() and method()?

The only time it matters is if you are using OuterClass.this.method() e.g.

class OuterClass {
    void method() { }

    class InnerClass {
        void method() {
            OuterClass.this.method(); // not the same as method().
        }
    }
 }

Leave a Comment