+ 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???

5th May 2017, 1:13 AM
Jullian Kline
Jullian Kline - avatar
4 Respostas
+ 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
5th May 2017, 1:18 AM
Complex
Complex - avatar
+ 6
We are happy to help =)
5th May 2017, 2:52 AM
Complex
Complex - avatar
+ 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.
5th May 2017, 1:26 AM
Jim
Jim - avatar
+ 1
so I declare it once and define it as much as I'd like. thanks guys! I get it! :D
5th May 2017, 2:48 AM
Jullian Kline
Jullian Kline - avatar