|
|
|
|
| The
Basic Elements of Java |
The basic elements
of Java include:
- Keywords - words
reserved for Java:
class,
float, return, etc.
- Primitive types
- specifies how values are stored in memory and what operations they
can undergo:
int, float, boolean, etc
- Operators:
+,-,/,*, etc.
- Declarations -
allocate memory for an instance of a particular type:
int
x; double y=1.0; etc.
- Literals
- immediate values
:
int
i = 3; <= 3 is a literal
double
x = 3.0; <= 3.0 is a literal
- Statements - express
an action to execute:
x=5;
if( y<5) x= 3;
etc.
- Classes - provide
the data structure and operations for a new type. Objects are instances
of a class.
Note that Java syntax
has much in common with C/C++.
However, there are
many small, as well as not so small, differences.
|