"this." tag?

Discussion in 'Plugin Development' started by Quaro, Oct 18, 2013.

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

    Quaro

    When i have to use "this." tag, before function/variable? (need explanation, im beginner)


    And could someone explain this?
    Code:java
    1. public String test;
    2. public Class(String test, Class plugin)
    3. {
    4. this.test = test;
    5. }
    6.  
     
  2. Offline

    1Rogue

    "this." represents the current instance of the class you are using. It is just good coding practice.

    Note you cannot use it in static cases, since there is only ever one instance of static objects.
     
  3. Offline

    Garris0n

    There's a good chance he doesn't really understand instances. This is a bukkit help forum, not a java help forum. Learn the language before you get into bukkit.
     
  4. Offline

    Quaro

    Garris0n Could you recommend any tutorial, for this?
     
  5. Offline

    1Rogue

  6. Offline

    Garris0n

    TheNewBoston makes good tutorials, never actually watched his java tutorials but I hear they're good as well. You also probably want to get a Java book to use as a reference. Some people learn better from videos, some learn better from books, so you'll want to see which one is easier for you to understand. When you have issues you should always do plenty of searching before asking questions, as 99.9% of the time somebody else has already had a similar issue and you can find the answer (especially when you're just starting).

    Edit: And yes, as 1Rogue said, the official java tutorial is a fantastic resource as well.
     
  7. Offline

    lycano

    Micius i found this site very helpful in the beginning http://www.tutorialspoint.com/java/java_basic_syntax.htm

    It also increases the learning curve chapter by chapter so you are not asking too much questsions when you start.

    For instance he is not using "public, private, protected" keyword for class variables as long as you dont hit the chapter "Classes and Objects".
     
Thread Status:
Not open for further replies.

Share This Page