CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2018
    Posts
    8

    pass by value and pass by reference in Java?

    What is the difference between pass by value and pass by reference in Java?

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: pass by value and pass by reference in Java?

    Try searching in bing or google for "What is the difference between pass by value and pass by reference in Java?".

  3. #3
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    Re: pass by value and pass by reference in Java?

    There are no references in java
    Norm

  4. #4
    Join Date
    Feb 2017
    Posts
    677

    Re: pass by value and pass by reference in Java?

    Quote Originally Posted by kadammanali987 View Post
    What is the difference between pass by value and pass by reference in Java?
    The parameter passing mechanism in Java is always by_value. The by_reference passing mechanism doesn't exist in Java. It means whatever you pass (a primitive or a reference) to a method it will be copied before it is available in the method.

    It's important to understand that objects are always represented/handled indirectly by so called references in Java. A reference can be thought of as a "pointer" to an object. Therefore you could claim that "in Java an object is passed by its reference" but that doesn't mean the passing mechanism is by_reference (in the computer science sense of the term). So a reference is passed indeed but it is by_value, hence the confusion.
    Last edited by wolle; December 9th, 2018 at 07:09 AM.

Tags for this Thread

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

Featured