Question 'this' keyword

Discussion in 'Plugin Help/Development/Requests' started by mobkinz78, Aug 20, 2015.

Thread Status:
Not open for further replies.
  1. Offline



    I've been learning more and more Java recently, and am still a beginner. In a lot of plugins I have seen "registerEvents(this,this)" and am curious what the "this" keyword means. I am aware how methods and such work, but am still novice. For some reason, I still can't figure out the 'this' keyword.


    P.S. As far as I know, if I wrote this:

    int a = 1;
    public void method(int a){
    this.a = 5;

    It would mean that the variable a in the method equals 5. Not exactly sure if I'm write but that's what I think. Still confused what "this,this" are referring to in registerEvents.
  2. Offline


    Sorry for my terrible explanation but I'll try to explain it.

    The keyword "this" just essentially means you're referring to the class you're in.

    For example I could have 2 "int a"'s in different classes and if I put "this.a" that means I'm referring to the one in the class you're coding in now. If that makes sense.
Thread Status:
Not open for further replies.

Share This Page