R
Roedy Green
The objects are indeed passed by reference.
The JLP smacks you down for claiming it does. Did you ever see the
Monty Python sketch about the Bulgarian-English phrase book?
The objects are indeed passed by reference.
but i can't help, String is a object, so a reference should be the one
passed, and why we can not update the field in the String object? and
then where is the field of the String?
Yes, I was wrong in my
public void myFunc(String s) {
s = "123";
}
because that compiles exactly as
public void myFunc(String s) {
s = new String("123");
}
public void myFunc(String s) {
s.setValue("123");
}
but it does not, and we can't.
Some kind of a wrapper class is needed with the methods required.
Local copies will be made of the int and of the reference, but not of the
object. Let's say these local copies are stored in 0x4000 and 0x5000:
it is also the most commonly frowned on approach.The most common pattern is just to use an array to pass the object
reference.
Roedy said:it is also the most commonly frowned on approach.The most common pattern is just to use an array to pass the object
reference.
Returning an Object[] of kitchen sink item is like using machine
I'd like to define a method where several values can be returned. any
idea?
Eeeeewwwww. I would definitely pass an array before I did something ugly
like that.
And here I could have sworn I used String, not Object.
Patricia Shanahan said:I don't think this one is just hairsplitting. The "objects passed by
reference" model does not explain what happens when the actual argument
is a null reference.
Roedy Green said:The JLP smacks you down for claiming it does. Did you ever see the
Monty Python sketch about the Bulgarian-English phrase book?
Roedy said:I discuss that at http://mindprod.com/jgloss//multiplereturn.html
Peter said:[...]
Another approach is to use separate methods to retrieve the results,
perhaps after a call to compute them.
Eeeeewwwww. I would definitely pass an array before I did something
ugly like that.
I discuss that at http://mindprod.com/jgloss//multiplereturn.html
--
Andreas said:With "pass me the sugar please", one doesn't explicitly state that the
sugar is actually in a jar, and that it's really the jar that will be
(hopefully) handed back to the one who asked for it.
I'd like to know more about this Intellij Idea and returned classes in
this case, any sample and use of Idea to achieve this?
Thanks,
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.