Posted: 10/17/2010
Hello Folks,
Value Type - Value type variables directly contains values and stored on the stack.
Reference Type - Reference type do not hold the actual data for the object.When a reference type instance is created store the address of their data on the stack and actual data stored on the heap.
Example -
Int a=5;
String B="Mohit";
MEMORY diagram -
Copy -
Int C = A;
String B = D;
Its mean - Changing the value of one value type(A) does not affect the value of another value type(C). but in case of reference type if I will change value of B, it would effect on value of D also.
Am I right?
Please tell me if I am right or wrong:)
Thanks in advance.
In your case it won't affect because the answer is that strings are immutable. They will still have different values.
raghav_khunger said: user="Raghav Khunger"]In your case it won't affect because the answer is that strings are immutable. They will still have different values.
user="Raghav Khunger"]
What about my memory Diagram image sir?
Like I want to know in normal case Value type variables directly contains values and stored on the stack and when I copy, it will create a new memory allocation.When a reference type instance is created store the address of their data on the stack and actual data stored on the heap.
Is my statement right in normal case??