Hi,
I just want to know is arrays the only one will be pass by reference?
Regards,
Shamran.
About Question enthuware.ocajp.i.v7.2.1252 :
Moderator: admin
-
- Posts: 15
- Joined: Wed May 10, 2017 2:49 am
- Contact:
-
- Site Admin
- Posts: 10053
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1252 :
No, in Java, everything is passed by value. But in case of objects (any object, including arrays) it is the value of the reference that is passed by value. It is a very important topic so I will suggest you to go through a good book to understand it. Here are a few good links -
http://javadude.com/articles/passbyvalue.htm
and
http://stackoverflow.com/questions/4048 ... s-by-value
http://javadude.com/articles/passbyvalue.htm
and
http://stackoverflow.com/questions/4048 ... s-by-value
If you like our products and services, please help us by posting your review here.
-
- Posts: 37
- Joined: Mon Jun 12, 2017 2:16 am
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1252 :
And why does the compiler not put an implicit this before the c in m2()
-
- Site Admin
- Posts: 10053
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1252 :
Because a variable named c is already in scope. The compiler tries using "this" (or the classname to use the static variable) only if it is not able to resolve the given variable. Here, it is already able to resolve c as a method parameter. So there is no need to use "this".horst1a wrote:And why does the compiler not put an implicit this before the c in m2()
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 42 guests