unit 1
unit 1
Primitive Types
Hello World
computer monitor.
/*
This
is
multi line
comment
*/
Keywords
Keywords
keywords are also known
as reserved words.
Keywords are particular
words which acts as a key to
a code. These are predefined
words by Java so it cannot be
used as a variable or object
name
Constant
Data Type
Data Types
Data Types
int
•Integer is generally used as the default data type for integral values
• This data type is generally used as the default data type for decimal
• Double data type should never be used for precise values such as
currency
• This data type is used for simple flags that track true/false
conditions
location
modify
5 4
Variables
location
5
Variables
• Variable is name of reserved area allocated in memory. In other
words, it is a name of memory location
• Based on the data type of a variable, the operating system allocates
memory and decides what can be stored in the reserved memory
• It is a combination of "vary + able" that means its value can be
changed
location variable
data type
5 value
Variables
Identifier
• Identifiers in Java are symbolic names used for identification.
They can be a class name, variable name, method name,
package name, constant name, and more.
• Key words can not be used as an identifier
A 0, 1, 2 A 1, -1, 4
B 1, 2, 3 B -1, 2, 3
C 2, 2, 3 C -1, 2, 2
D 0, 0, 3 D -1, 2, 2
E -1, 2, 4