I heard that variables are stored in stack and objects are stored in heap.
If i declare variable as var password= "abc"
.Now where this password is going to store(heap /stack)
I heard that variables are stored in stack and objects are stored in heap.
If i declare variable as var password= "abc"
.Now where this password is going to store(heap /stack)
Where an object is stored is not something you should be worrying about in the general case, but, as everytime this question crops up in SO, commentaries and answers crop up spreading the mythical and false belief that value types are stored in the stack and reference types are stored in the heap. No, no and no!
Thnink of it this way, its better: reference types go on the heap, short lived value types go on the stack. Long lived value types (fields, captured variables in a closure) go on the heap. The storage mechanism has very much to do with the expected lifetime of a variable, its not all about the nature of the type of the variable.
If you really want to know the details, read this.