Page 313 - CITS - Computer Software Application -TT
P. 313
COMPUTER SOFTWARE APPLICATION - CITS
Basic JAVA language elements keywords, comments,
data types and variables
Keywords
There are certain words with a specific meaning in java which tell (help) the compiler what the program is supposed
to do. These Keywords cannot be used as variable names, class names, or method names. Keywords in java are
case sensitive, all characters being lower case.
Keywords are reserved words that are predefined in the language; see the table below (Taken from Sun Java
Site). All the keywords are in lowercase.
Comments
Comments are descriptions that are added to a program to make code easier to understand. The compiler ignores
comments and hence its only for documentation of the program.
Java supports three comment styles.
Block style comments begin with /* and terminate with */ that spans multiple lines.
Line style comments begin with // and terminate at the end of the line. (Shown in the above program)
Documentation style comments begin with /** and terminate with */ that spans multiple lines. They are generally
created using the automatic documentation generation tool, such as javadoc. (Shown in the above program)
Data Types in Java
Data types specify the different sizes and values that can be stored in the variable. There are two types of data
types in Java
1 Primitive data types: The primitive data types include boolean, char, byte, short, int, long, float and double.
2 Non-primitive data types: The non-primitive data types include Classes, Interfaces, and Arrays.
Java Primitive Data Types
In Java language, primitive data types are the building blocks of data manipulation. These are the most basic data
types available in Java language.
There are 8 types of primitive data types
• boolean data type
• byte data type
• char data type
• short data type
• int data type
• long data type
• float data type
• double data type
300
CITS : IT&ITES - Computer Software Application - Lesson 78 - 84