Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By gimbal2

Thread: Java and "Passing by Reference"

  1. #1
    Salad7 is offline Member
    Join Date
    Nov 2014
    Posts
    3
    Rep Power
    0

    Default Java and "Passing by Reference"

    I know in C++ It's possible to pass by reference but what about java?

    for example, can i pass the address of a health variable into a Ninja class and then
    Since Ninja inherits from an enemy class pass the health into the enemy class
    and within there have a function that returns that same health address and takes 5 from the health returning 95.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Java and "Passing by Reference"

    We've only recently gone through a long discussion on this. You should be able to find your answer there.
    http://www.java-forums.org/new-java/...s-objects.html

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Salad7 is offline Member
    Join Date
    Nov 2014
    Posts
    3
    Rep Power
    0

    Default Re: Java and "Passing by Reference"

    Thanks!

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Java and "Passing by Reference"

    Post #6 of that thread especially has quite important links to read.
    DarrylBurke likes this.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Reading from a File, ArrayList and "reference"
    By pokadean in forum New To Java
    Replies: 5
    Last Post: 09-12-2013, 09:03 PM
  2. Replies: 0
    Last Post: 12-07-2012, 08:29 AM
  3. Replies: 3
    Last Post: 10-30-2012, 03:06 PM
  4. Replies: 1
    Last Post: 10-03-2011, 03:42 AM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Posting Permissions

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