ESC101 : Fundamental of computing
Lecture 3 (1 August, 2008)
After lecture 2, there were many students who said that they could not understand the later part of the
lecture. So in this lecture, I explained most of the stuff from lecture 2 again. I explained from scratch
the concept of variable - both declaration as well as operations on variable. The analogy between box
and variable was stressed once again. So if you have understood lecture 2 notes (also provided on the
website), then the only new things of lecture 3 were the following :
• Data types in Java
• The rules for identifiers
Following was a brief overiview of the above topics during the lecture.
Data Types in JAVA
In the previous lecture, we introduced notations for declaring and operating integer data items. Recall
again that each piece of data item has to be declared (mentioing its type and giving it a name/identifier)
before its use. In addition to integer, Java has data types for
• Fractional numbers (like 2.0, -3.6, 56.9675). The java types for these numbers are
– float
– double
• Booleans (true or false). The java type for Boolean is
boolean
• Characters (the key board characters and many more). The JAVA type for character is
char
We shall consider examples of the above data types in future lectures. However, please note that the rules
for declaring and updating the variables of the above data types is same as that of the integer variables
which were discussed at length in the lecture 2 and revised in this lecture as well.
Rules for identifiers
In the last lecture, we also mentioned that each word in the JAVA program created by the programmer,
for example while declaring a data item, is called anidentifier. An identifier has to be different from any
keyword, and in addition it must satisfy the folliwing rules :
• it must begin with some letter : a-z, A-Z, or the characters ,$.
• Each subsequent character must be either a letter, a digit 0-9, or characters ,$.
So the following words are not identifiers :
34i abc-d class
But the following words are identifiers :
i34 ab myname