+ 1
Why does it say to only declare the variable once but then that we can update and change it as often as you want?
so only define it once but change it whenever and when you change it only redefine it once each change???
4 odpowiedzi
+ 7
Actually when you do
int hey = 10;
or
int hey;
It is called variable declaration, the variable now exists. But you can define them again like this
int x = 10;
x = 20;
x = 40;
Define is when you give value to the variable, declaration can be done only once whilst defining variables is up to you
+ 6
We are happy to help =)
+ 2
Think about it this way:
When you declare a variable, you're creating a box to hold some data of a certain type.
Then you can put the one bit of data in that box (this is what you do when you assign the variable), and then peak at it (access/use the variable), or trade out the data (reassign the variable).
It's not a great analogy, but it might help.
+ 1
so I declare it once and define it as much as I'd like. thanks guys! I get it! :D