No, that's incorrect. One important property of pass-by-reference is that after passing the 'variable' to another context, this other context can change what the original 'variable' holds. In Java the variable holds a reference and the reference points to an object. You can definitely change the object being pointed too, but you can NOT change what the original variable holds.
That makes it just "passing a reference by value". It's true that the term 'reference' is confusing here. It may sounds better if you just say a pointer is passed by value.
Yes, I am fully aware of that. Thats why I agreed that it was "pass by value", not "pass by reference". Good job in reading my post. However, the values in Java are usually references (assuming they are objects, not primitives), so the thing that you usually want to change (the object, not the reference) can be changed.
The things you end up passing around are values of references. Thus for most purposes, it is effectively pass by reference.
This is just a silly Lisp lamer whining about what he doesn't like about Java. I could get a list of Lisp features and write a blog about how much I hate each one. Yip-eee. He's completely wrong on many points as well.
This is what's wrong with dzone. Junk like this should not get to the front page. Only put stuff on front page that has at least 20 or 30 positive votes!
Either that, or have the down votes counter-balance the up votes to some degree. The way it seems to work now is that a post can have 10 down votes, but once it gets 4 ups, it's on the front page regardless of how idiotic the referenced content might be.
Comments
rjminniear replied ago:
Some of these are good, although the statement that Java is uses pass-by-reference for object types is incorrect. Java always uses pass-by-value.
Nick Brown replied ago:
Technically yes, except "object types" are always references, so it is effectively pass-by-reference.
henk replied ago:
No, that's incorrect. One important property of pass-by-reference is that after passing the 'variable' to another context, this other context can change what the original 'variable' holds. In Java the variable holds a reference and the reference points to an object. You can definitely change the object being pointed too, but you can NOT change what the original variable holds.
That makes it just "passing a reference by value". It's true that the term 'reference' is confusing here. It may sounds better if you just say a pointer is passed by value.
E.g.
Foo foo1 = new Foo();
Foo foo2 = foo1;
func ( foo );
// always true, func can never change what foo1 was pointing too.
assert ( foo1 == foo2);
Nick Brown replied ago:
Yes, I am fully aware of that. Thats why I agreed that it was "pass by value", not "pass by reference". Good job in reading my post. However, the values in Java are usually references (assuming they are objects, not primitives), so the thing that you usually want to change (the object, not the reference) can be changed.
The things you end up passing around are values of references. Thus for most purposes, it is effectively pass by reference.
bloid replied ago:
But all these things are surely known about as you enter into the Java world (or soon after)?
I could complain that C doesn't handle Objects, or that Assembler doesn't natively do regexp, but wouldn't people label me a fool?
Also, I hate the way rain is wet
sproketboy replied ago:
This is just a silly Lisp lamer whining about what he doesn't like about Java. I could get a list of Lisp features and write a blog about how much I hate each one. Yip-eee. He's completely wrong on many points as well.
This is what's wrong with dzone. Junk like this should not get to the front page. Only put stuff on front page that has at least 20 or 30 positive votes!
dglasser replied ago:
Either that, or have the down votes counter-balance the up votes to some degree. The way it seems to work now is that a post can have 10 down votes, but once it gets 4 ups, it's on the front page regardless of how idiotic the referenced content might be.
Voters For This Link (12)
Voters Against This Link (18)