

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The concept of variables and declarations in java programming language. It discusses strong typing, the importance of variable declarations, and java conventions for naming variables. It also includes examples and interactive exercises.
Typology: Study notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


A variable is a name with an associated value. Throughout this course, we draw a variable as a named box with the value in the box. For example, here is a variable x associated with the value 5. Sometimes, we draw a line instead of a box, as shown to the right below: Java is strongly typed , meaning that it has properties like the following.
(2) The identifier does not start with a number. But most Java programmers follow the convention that (1) Identifiers do not contain '$' —this char is used at times by the compiler. ( 2 ) The first letter of a variable name is not a capital. ( 3 ) If the name consists of a series of words, the first letter of each word is capitalized, and Here are examples of good variable names: apple numberOf7s isEven numberOfChildren The length of variables names is always a cause for argument. Make them too short, and you don’t know what they mean. Make them too long, and the program looks cluttered and unwieldy. Later, we give conventions for variable names depending on where they are declared, keeping them short if their use is close to the declarations and making them longer if their use if far from their declarations.