Variable naming is an important aspect of programming. The names should not only convey the meaning, but also follow the syntactic rules, which, as a rule, are not checked at all at the level of the language, but are necessary during development. The process of writing programs in the modern world is teamwork, and for better teamwork in a team, the code is written in the same style, as if one person was working on it.
The naming of variables can be divided into three main approaches, which sometimes combine with each other. All these approaches manifest themselves when the variable name consists of several words:
- kebab-case - the variable components are separated by a hyphen. For example:
- snake_case - underscore is used for separation. For example:
- CamelCase - each word in a variable is written with a capital letter. For example:
In Java, CamelCase and its variation lowerCamelCase are used, in which the first letter of the first word is lowercase. It is lowerCamelCase that is used for variables.
Another common rule is: do not use transliteration for names, only English. If you experience difficulties with English, use a translator. Over time, digging into someone else’s code, you will form the right concepts for naming.
Create two variables with the names “first number” and “second number” using lowerCamelCase. Write in the first variable the number
1.10, in the second -
-100. Display the product of the numbers written in the resulting variables.
The code will work with any names, and our system always checks only the result on the screen, so the execution of this task is under your responsibility.
Please sign in with your GitHub account, this is necessary to track the progress of the lessons. If you do not have an account yet, now is the time to create an account on GitHub.