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: how does the keyword "this" work?

  1. #1
    Junior Member
    Join Date
    Apr 2023
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how does the keyword "this" work?

    hi im new to java and i was wondering about some of the keyword variables as ive already gotten the hang of some of the other ones such as int , do , for , while and so on but as i was looking at other peoples programs ( as i do it for guidance by the way ) i noticed the keyword this

    does anyone know what "this" does?

    please let me know

  2. #2
    Member Helium c2's Avatar
    Join Date
    Nov 2023
    Location
    Kekaha, Kaua'i
    Posts
    115
    Thanks
    1
    Thanked 3 Times in 3 Posts

    Default Re: how does the keyword "this" work?

    this() can be used to invoke the current class or constructor. As an action in support of an argument. System.out.printlin(this);
    public Main(int x) {
        this.x = x;
      }
    Last edited by Helium c2; November 30th, 2023 at 01:48 AM. Reason: add a part of a program

Similar Threads

  1. Conceptual Questions Related To "super" keyword and "constructor".
    By wikki2013 in forum Java Theory & Questions
    Replies: 1
    Last Post: May 26th, 2013, 02:14 PM
  2. Trying to understand the "protected" keyword.
    By simpson_121919 in forum Object Oriented Programming
    Replies: 3
    Last Post: April 30th, 2013, 08:57 PM
  3. Trying to get an "if" statement to work in a "for loop".
    By JAKATAK in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 1st, 2013, 11:16 PM
  4. [SOLVED] Adding the "final" keyword makes difference, I'm confused with the sequence flow.
    By SmokyBrain in forum Object Oriented Programming
    Replies: 2
    Last Post: April 30th, 2012, 01:50 AM
  5. Is "count" in this loop a keyword?
    By freakinawesome in forum Loops & Control Statements
    Replies: 5
    Last Post: April 25th, 2012, 04:25 AM