Results 1 to 3 of 3
  1. #1
    khorn06 is offline Member
    Join Date
    May 2014
    Posts
    1
    Rep Power
    0

    Default Lost when it comes to the keyword 'this'

    So I am learning Java and I am using the trails and tutorials that they offer. Currently I am on the trail about the keyword 'this'. I am completely stumped as I don't know why they have it and what I should be using it for or when I should use it? It seems like it is a pretty straight forward concept, yet I am still lost.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,417
    Rep Power
    25

    Default Re: Lost when it comes to the keyword 'this'

    "this" is a reference to the instance of the class where it is used. When code needs to pass a reference to the class it is in, use "this" as that reference.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,614
    Rep Power
    5

    Default Re: Lost when it comes to the keyword 'this'

    The 'this' keyword, simply means a reference of the current class instance in which it is used. It is most useful within constructors. What tutorials did you read? I can't explain it any better than here.

    Using the this Keyword (The Java™ Tutorials > Learning the Java Language > Classes and Objects)

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

Similar Threads

  1. this keyword
    By crazy in forum New To Java
    Replies: 6
    Last Post: 07-07-2013, 05:18 PM
  2. new keyword?
    By MW130 in forum New To Java
    Replies: 9
    Last Post: 05-08-2013, 03:26 PM
  3. The this keyword
    By Army in forum New To Java
    Replies: 15
    Last Post: 12-14-2012, 04:01 AM
  4. this keyword
    By coltragon in forum New To Java
    Replies: 10
    Last Post: 03-01-2010, 09:20 AM
  5. Use of this keyword
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-18-2007, 07:32 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •