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 3 of 3

Thread: the pass by reference technique in java

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question the pass by reference technique in java

    Hello,

    I'm new in the java world and was wondering if there is a possibility to use the pass by reference technique in java like in C++.
    I'm using this book as my reference but I think there is no way to do that.

    it-book-recommendations.com/departments/programming%20languages/java/index.html

    Thanks in advance.


  2. #2
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: the pass by reference technique in java

    Not exactly, but there is a little trick if you really want to do it, just use a one-element array instead.
    But, it is more recommended to simply do a more java-apropriate program design.

  3. #3
    Member jdv's Avatar
    Join Date
    Jul 2014
    Location
    This Land
    Posts
    73
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default Re: the pass by reference technique in java

    Quote Originally Posted by dean_corso View Post
    Hello,

    I'm new in the java world and was wondering if there is a possibility to use the pass by reference technique in java like in C++.
    Remember that objects in Java are passed by value, though the value they are passing for an object is a pointer/reference to the object. So you have access to an object as if you had the * operator, just like in C++.

Similar Threads

  1. Can't pass by reference?
    By JavaDeveloperPeter in forum What's Wrong With My Code?
    Replies: 31
    Last Post: August 25th, 2014, 12:53 PM
  2. Need a algorithm format of Butterfly Sub division technique
    By balaji040 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 17th, 2014, 04:26 AM
  3. [SOLVED] Pass-by-Value scheme, puzzled with passing/assigning a reference to another object
    By chronoz13 in forum Java Theory & Questions
    Replies: 10
    Last Post: June 2nd, 2012, 10:43 AM
  4. What are the 3 types of self-reference in JAVA
    By wholegrain in forum Java Theory & Questions
    Replies: 1
    Last Post: March 5th, 2012, 05:49 PM
  5. 'pass by value' and 'pass by reference'
    By pokuri in forum Object Oriented Programming
    Replies: 5
    Last Post: January 26th, 2011, 11:30 AM