The Integer Variable
The Int variable is a variable that can only host numerical values. These values cannot contain a decimal, or the values after the decimal will always be ignored.
Declaration format is almost the same, except it cannot contain letters or symbols:
int yourVariableName =0;
Some examples of how Java will treat Int mathematics.
This code is fully functional:
int twoHundred = 200;
This code is will not function:
int twoHundredPointFive = 200.5;
Integers may not contain a value beyond the decimal, they must be entirely whole numbers.
Doubles are declared in the same way as integer variables.
This code is fully functional:
double twoHundredPointFive = 200.5;
This code is ALSO fully functional.
double twoHundred = 200;
Please watch the video I made on this subject if you'd like an example of where and how to declare a variable that contains an integer.
DETAILED VIDEO BELOW
Lol computer games then and now
No comments:
Post a Comment