+ 5
What are value types and references types?
5 ответов
+ 4
Value types stores their contents in the memory allocated from stack but reference types don't have any content but they store the address of other value type content. Value type variables are stored in stack and reference type are stored in heap memory area.
+ 1
value type is when we declared variables e.g int x=10 then this is a value type and it is stored in a memory location is known as Stack.
Reference Type is when we create class objects
e.g:
class Sharp
{
int x;
}
static void Main(String[] args)
{
Shape s=new Shape(); //object
}
then data for that object is stored on heap and memory address is on the stack that is why it is known as reference type
0
variabls value of location
0
haaa
- 1
hmm