Results 1 to 3 of 3

Thread: ' this. '

  1. #1
    helloworld is offline Member
    Join Date
    Sep 2008
    Posts
    11
    Rep Power
    0

    Default ' this. '

    I would like to know for this abstract,

    public Temperature(double number) {
    this.number = number;


    what does the 'this' refer to?

    Thanks.

  2. #2
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    6

    Default

    this refers to the current class,in your case this.number monitors to class variable which was declared in the class which is assigned to a parameter double number.

  3. #3
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Location
    Southwest
    Posts
    1,018
    Rep Power
    7

    Default

    static always same for all classes. this only applies to classes generated with new keyword.

    You will sometimes hear of this discussed as stack and heap.....
    Introduction to Programming Using Java.
    Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor

Posting Permissions

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