In this blog I will tell you some common differences between
value types and reference types.
Value types are those type of data type which
will store value and reference type are those type of data type which will
store addresses of variable rather than value.
Value types are stored in stack part of memory
while reference types are stored in heap part of memory.
The default value which is initialized in value
types are 0, false, ‘\0’ etc while in reference types the default value are initialize
When we assign the value of one value type
variable to another type of variable then it simply copy value of variable and
when we use assignment operator in case of reference variable then it copy
address of variable rather than value.
Following example represent value type variable.
int i=17; int j=I;
Following example will represents
use of reference variable.
String sMessage=”Hello World”;