A reference

Discussion in 'Java' started by Robert Mark Bram, Aug 24, 2003.

  1. Howdy All!

    int number = 3;
    Object obj = new Object();

    Would I correct in saying:
    - as a primitive, the value of number is 3;
    - as an object reference, the value of obj is a "reference" to the object
    variable created on the rest of the line.

    Thus..

    int number1 = 3;
    int number2 = 3;
    Object obj1 = new Object();
    Object obj2 = new Object();

    number1 == number2;
    True because their values are equal (3 == 3).

    obj1 == obj2;
    False because their values are different (obj1's value is a reference to the
    first object: obj2's value is a reference to the second object).

    Thanks for any assistance!

    Rob
    :)
    Robert Mark Bram, Aug 24, 2003
    #1
    1. Advertising

  2. Robert Mark Bram

    David E. Guest

    correct... you answered your own question :)



    "Robert Mark Bram" <> wrote in message
    news:3f483e79$0$14558$...
    > Howdy All!
    >
    > int number = 3;
    > Object obj = new Object();
    >
    > Would I correct in saying:
    > - as a primitive, the value of number is 3;
    > - as an object reference, the value of obj is a "reference" to the object
    > variable created on the rest of the line.
    >
    > Thus..
    >
    > int number1 = 3;
    > int number2 = 3;
    > Object obj1 = new Object();
    > Object obj2 = new Object();
    >
    > number1 == number2;
    > True because their values are equal (3 == 3).
    >
    > obj1 == obj2;
    > False because their values are different (obj1's value is a reference to

    the
    > first object: obj2's value is a reference to the second object).
    >
    > Thanks for any assistance!
    >
    > Rob
    > :)
    >
    >
    David E., Aug 24, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darren
    Replies:
    0
    Views:
    479
    Darren
    Oct 11, 2004
  2. Dude
    Replies:
    0
    Views:
    334
  3. ce
    Replies:
    1
    Views:
    2,958
  4. sam pal
    Replies:
    3
    Views:
    514
    E. Robert Tisdale
    Jul 16, 2003
  5. Craig Nicol
    Replies:
    2
    Views:
    452
    Craig Nicol
    May 10, 2004
Loading...

Share This Page