Results 1 to 5 of 5
Thread: How to Pass byref in Java
- 08-25-2010, 05:50 PM #1
Senior Member
- Join Date
- Jan 2010
- Posts
- 138
- Rep Power
- 0
- 08-25-2010, 06:32 PM #2
Java copies everything by value.
To "pass by reference" you will have to wrap primitives in an object, and pass a reference to it.
You may want to look Q&A : How do I pass a primitive data type by reference?, its a fairly simple and clear explanation in my opinion (also the first result from google)
Hope this helps,
if you need a clearer explanation just ask
Berkeleybross
- 08-25-2010, 06:58 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
- 08-26-2010, 03:00 AM #4
Senior Member
- Join Date
- Jan 2010
- Posts
- 138
- Rep Power
- 0
Hi JosAh,
so how to return multiple values? ..
in my case below .. I have to return boolean and the math result?
private boolean getPassByRef(int a, int b, ref int c) {
boolean ret1 = false;
int ret2 = 0;
ret2 = (a * b) + 3;
c = ret2;
ret1 = true;
return ret1;
}
-
If you must return multiple types of information, one way is to create a class that holds various types and return an object of the class.
Similar Threads
-
Pass String Value
By DJCali in forum New To JavaReplies: 2Last Post: 03-03-2010, 12:48 AM -
How to pass user-id between .java programs
By mkkrish in forum AWT / SwingReplies: 4Last Post: 12-22-2009, 04:30 PM -
how to pass data
By rakesh_mca in forum Java ServletReplies: 7Last Post: 10-25-2009, 01:13 PM -
Pass-by-reference
By popjava in forum New To JavaReplies: 1Last Post: 10-19-2009, 03:45 PM -
how to pass array in java?
By sivasayanth in forum New To JavaReplies: 3Last Post: 01-13-2008, 04:33 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks