So what does variables do? (In relistic situation) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

So what does variables do? (In relistic situation)

5th Jan 2017, 11:09 PM
MOSES DYE
MOSES DYE - avatar
3 Answers
+ 7
A variable is essentially a memory location (literally an address in your RAM) that you give can a name and refer to by its name rather than its memory address. int i = 0; This line of code asks the system for a free memory location capable of storing a 32bit integer and assigns its value to 0. I hope this helps.
6th Jan 2017, 1:29 AM
Laurence Turner
Laurence Turner - avatar
+ 2
They're used when you don't know what their value's gonna be (e.g. when using if or switch) or when you need to use some value often (e.g. content from a file, which you would otherwise have to read every time you need that data). Look around on the playground and you'll see.
6th Jan 2017, 12:21 AM
Maike
0
more information... the framework predict when is possible free memory with GC (garbage collector), If the variable is not use on the context...
7th Jan 2017, 4:00 PM
Roberto De Almeida
Roberto De Almeida - avatar