Variables are names for every information you save in Java.
Why use types? (String, int, double)
Different Variables
In Java, 2 kind of variables exists, variables containing:
CONSTANTS |
JUST VALUES |
If a value can be used multiple times you make it constant. The rest are just values because of its uniqueness .
Example
You can see the different color circles.
CONSTANTS |
JUST VALUES |
· “hit the gym!”
· “black” |
· “Jack the Programmer”
· 60 · 1.90 |
why?
Hobby and hair color are characteristics that could be the same for many people. Name is definitely some unique value. However, you can argue about age and length, in this example we say it are unique values, with not so much similarities among other people.
programming language
We should rewrite the above code; WORK AS MUCH WITH CONSTANTS AS POSSIBLE
How to write:
CONSTANTS (also some info about FINAL and STATIC) |