Results 1 to 5 of 5

Thread: Does Java call by reference or by value?[resolved]

  1. #1

    Thread Starter
    Hyperactive Member Pix's Avatar
    Join Date
    Feb 2001
    Location
    I'm not telling you (or them)
    Posts
    282

    Question Does Java call by reference or by value?[resolved]

    I always thought that Java called things by reference because it calls the address and not the value itself, but according to my lecturer it always calls by value, which seems a bit strange to me. Just wondered if someone could explain how it is that Java always calls by value
    Last edited by Pix; Nov 23rd, 2001 at 10:26 AM.

  2. #2
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    I think Java passes its primitive data types such as int, char, double, etc. by value whilst it passes arrays and objects by reference. Strings can be considered as byval since a String cannot have its value updated, with the new value returned.

    But I'm no Java expert...
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  3. #3
    But you're exactly right.

  4. #4
    PowerPoster Arbiter's Avatar
    Join Date
    Sep 2000
    Location
    Manchester
    Posts
    2,276
    Cool as!

    Shows I have some uses then. That's the only post I've felt competent enough to make in here - I didn't know if I was talking complete bollocks or not, but I'd thought I'd take the risk to help Pix out....
    Gentile or Jew,
    O you who turn the wheel and look to windward,
    Consider Phlebas, who was once handsome and tall as you...

  5. #5

    Thread Starter
    Hyperactive Member Pix's Avatar
    Join Date
    Feb 2001
    Location
    I'm not telling you (or them)
    Posts
    282
    Thank you

Posting Permissions

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



Click Here to Expand Forum to Full Width