Suhaas Mohandos wrote:1. So if I use new in the called method, the change will not be reflected in the calling method?
Suhaas Mohandos wrote:2. If you are saying primitives are pass by value and objects are also passed by value in java then give me a fresh example of both(primitive and object) where the change is not reflected in the calling method?
Suhaas Mohandos wrote:3. When they say java is pass by value does it mean that changes made in the called method will not affect the calling method?
raja singh kumar wrote:We know that arrays are objects in java. In the below example am I passing an object or value?
.you are passing "reference(val,to array object") as argument in method "change".
raja singh kumar wrote:I believe we are passing a reference to the object.How is the caller method having modified value? Is it because we are actually modifying the object and not changing the reference?
raja singh kumar wrote:In the below code how do I make the change made in m1 method to reflect in main method?
raja singh kumar wrote:In the below code how do I make the change made in m1 method to reflect in main method? I dont want to change the return type of m1 method
raja singh kumar wrote:Well I found one vague solution. Does anyone have a better one than this?
raja singh kumar wrote:But I want to have a common boolean value which is shared by multiple classes and change made to the boolean variable in any of the classes should be visible to all the classes. How do I do that?
raja singh kumar wrote:Is it not true that reference in Java is similiar to a pointer in C++?
raja singh kumar wrote:
static variable is shared by objects of the same class. I want a solution where I can share a common boolean value across classes.
raja singh kumar wrote:Can someone post an example where multiple classes update the same shared variable?