Java is a "descendent language" of C:
|
Signed number data types
byte (Java) / char (C) short int long float double |
Note: C also has unsigned integer data types
Syntax to define variables:
char a; // char data type in C is equivalent to byte in Java short b = 4; // Initialization has the same syntax int c; float x; double y; |
The arithmetic operators:
+ - * / % |
The assignment operators:
= += -= *= /= %= |
The pre/post increment/decrement operators:
++x --x x++ x-- |
The comparison operators:
< <= > >= == !=
|
The logical operators:
&& || !
|
All the statements:
Assignment statement:
x = (a + b) * (c + d % e);
Conditional statement:
if ( a > b )
max = a;
else
max = b;
Switch statement:
switch ( x )
{
case 1: y = 1; break;
case 2: y = 2; break;
default: y = 3; break;
}
|
All the statements: (continued)
Loop statement:
while ( x < 10 )
x++;
for ( i = 0; i < 10; i++ )
sum += i;
do
{
x = x + 1;
} while (x < 10)
Loop control statements:
continue
break
|