Save
lecture 3
Save
Share
Learn
Content
Leaderboard
Learn
Created by
Minito
Visit profile
Cards (10)
Variable
A named quantity that is stored in the computer memory (
RAM
)
Variable
Different types
such as double, integer, character, etc.
Computers store them
differently
based on their
memory
requirements
In Java, the compiler needs to know the
type
of variable being used
first
Variable types
Integer
Double
Character
String
Primitive data types in Java
Byte
Short
Int
Long
Float
Double
Char
Boolean
Primitive
data types
The basic data types in Java
Choosing a suitable variable name
1. Start with a letter,
underscore
or
dollar
sign
2. Can contain
letters
and digits 0-9 after first character
3. No
spaces
or
special
characters
4. Case
sensitive
5. Avoid using Java
keywords
Variable names that describe the data stored are called
mnemonic
variables
Assignment
operator (=)
Used to initialize a variable with a
value
Unary
operators
Increment
(++)
Decrement
(--)
Negation
(-)
Logical complement
(!)