Wednesday, October 26, 2016

Lesson 1.1 - Variables

Also keep in mind, the examples are java syntax.
more on Variables tho ... before the challenge comes ...
Note that anytime I put some words after // it means I am trying to provide extra information or making additional comments
real Examples of variables in Java are in the format
type variableName

int heightVariable;     // integer variable 
int highestSpeedICanWalk;    //notice another integer variable
string myNameIsHere;       //this is a string variable
decimal litres          //this is variable that can store decimal 

have no spaces and no hyphens but they can have underscores 🙂

As I mentioned before variables are like buckets and we put stuff in buckets. for instance

int mySpeed;
mySpeed = 6 //I just put the value of 6 into the mySpeed bucket aka variable

you can also put another variable into another variable (if an only if they are of the same type) for example
int theBrightness = 12;
int theVolume = 7;
theBrightness = theVolume

I just gave the value of theVolume to theBrightness so now, the value of theBrightness is equal 7 which is equal to the value of theVolume

Its like I pour the content of theVolume into theBrightness. In programming, we always pour from right to left. Yep .. we assign variables from right to left. (U will get used to this soon)

No comments:

Post a Comment