Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: What are the 3 types of self-reference in JAVA

  1. #1
    Member
    Join Date
    Feb 2012
    Posts
    96
    Thanks
    15
    Thanked 1 Time in 1 Post

    Default What are the 3 types of self-reference in JAVA

    I know this.variable = variable is one of them, but forgot the others.


  2. #2
    Member snowguy13's Avatar
    Join Date
    Nov 2011
    Location
    In Hyrule enjoying a chat with Demise and Ganondorf
    Posts
    339
    My Mood
    Happy
    Thanks
    31
    Thanked 48 Times in 42 Posts

    Default Re: What are the 3 types of self-reference in JAVA

    You can use the keyword this to have an object refer to itself:

    public class SR
    {
       int number;
       public SR(int number)
       {
          //Use "this" to refer to the "number" in this object, since "number" is also a parameter
          this.number = number;
       }
    }
    Use highlight tags to help others help you!

    [highlight=Java]Your prettily formatted code goes here[/highlight]

    Using these tags makes your code formatted, and helps everyone answer your questions more easily!




    Wanna hear something funny?

    Me too.

Similar Threads

  1. Replies: 1
    Last Post: February 14th, 2012, 07:42 AM
  2. Replies: 9
    Last Post: November 5th, 2011, 10:22 AM
  3. Java Poster : Quick Reference guide.
    By SkroefAudio in forum The Cafe
    Replies: 6
    Last Post: September 12th, 2011, 10:56 AM
  4. Object Reference
    By Mr.777 in forum Object Oriented Programming
    Replies: 2
    Last Post: June 13th, 2011, 03:03 AM
  5. Object as Reference not working
    By jassi in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 9th, 2010, 09:47 AM