how to pass a parameter by reference to a method?

i got a viriable of a double type principal and want to pass it by reference to a method called setDoubleValue(TextField textField,double principle),how can i do that?
[174 byte] By [zhongxun_UKa] at [2007-10-1 1:13:11]
# 1
Use a Double instead of a double. Double is the object wrapper for the primitive double. See http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Double.htmlObjects are passed to methods by reference ehile primitives are passed by value.
EdenMonaroa at 2007-7-8 1:29:42 > top of Java-index,Security,Event Handling...
# 2

> Objects are passed to methods by reference ehile

> primitives are passed by value.

Oh brother, here we go again...

No, EVERYTHING is passed by value. The object reference is passed in by value as well. If the object is mutable, you can call methods on it to change its state. However, that won't work for Double, as Double is immutable anyways.

warnerjaa at 2007-7-8 1:29:42 > top of Java-index,Security,Event Handling...
# 3
thank you!
zhongxun_UKa at 2007-7-8 1:29:42 > top of Java-index,Security,Event Handling...
# 4
is there any means to pass double or Double by reference?
zhongxun_UKa at 2007-7-8 1:29:42 > top of Java-index,Security,Event Handling...
# 5
another language, maybe?
bsampieria at 2007-7-8 1:29:42 > top of Java-index,Security,Event Handling...
# 6

> is there any means to pass double or Double by

> reference?

No.

The reason for this is because you want to modifiy it?

Then do one of the following...

- The method returns a value, there it is.

- You pass in an array, modify the contents of the array

- Create your own object. Pass it in. Modify the contents.

jschella at 2007-7-8 1:29:42 > top of Java-index,Security,Event Handling...
# 7

> > Objects are passed to methods by reference ehile

> > primitives are passed by value.

>

> Oh brother, here we go again...

> No, EVERYTHING is passed by value. The object

> reference is passed in by value as well. If the

> object is mutable, you can call methods on it to

> change its state. However, that won't work for

> Double, as Double is immutable anyways.

Isn't the first point a little pedantic? The second point has merit though.

EdenMonaroa at 2007-7-8 1:29:42 > top of Java-index,Security,Event Handling...
# 8
> Isn't the first point a little pedantic?It's one of those "pedantic" things that make everything appear much clearer once you understand them.
DrClapa at 2007-7-8 1:29:42 > top of Java-index,Security,Event Handling...
# 9
> Isn't the first point a little pedantic?Not when you've gone and said something like "Objects are passed to methods by reference ehile primitives are passed by value" it isn't.
Adeodatusa at 2007-7-8 1:29:42 > top of Java-index,Security,Event Handling...
# 10
"ehile" should read "while"I understand conceptually that you pass an object handle and not the object itself. Perhaps if I ever start thinking in Java then the distinction will be apparent.
EdenMonaroa at 2007-7-8 1:29:42 > top of Java-index,Security,Event Handling...
# 11

> "ehile" should read "while"

>

> I understand conceptually that you pass an object

> handle and not the object itself. Perhaps if I ever

> start thinking in Java then the distinction will be

> apparent.

Or perhaps, grasshopper, when the distinction becomes apparent, you will be ready to take the first step down the path toward thinking in Java.

But seriously. Passing a reference by value is conceptually similar to passing an object by reference. However, given that Java's types include references but not objects, it makes more sense and fits better with the definition to say references are passed by value. That is in fact what happens--the refrence has a value (the "address," in a sense, of an object) and that value is duplicated and passed.

jverda at 2007-7-8 1:29:42 > top of Java-index,Security,Event Handling...
# 12
> "ehile" should read "while"Imagine that. Well, that makes everything you said so much more sensible.:pEveryone makes typos, and you're crazy if you think I was commenting on yours.
Adeodatusa at 2007-7-8 1:29:42 > top of Java-index,Security,Event Handling...
# 13
> I understand conceptually that you pass an object> handle and not the object itself.In Java that "handle" is called object reference.
uj_a at 2007-7-8 1:29:42 > top of Java-index,Security,Event Handling...