JAVA
Declaring
a Variable:
dataType variableName;
int i;
char ch;
boolean found;
Assignment :
variable = expression;
int i = 0;
short x = 0xBF;
float area = length * width;
Constants :
final datatype CONSTANTNAME = VALUE;
final double PI = 3.14159;
final int RATE = 6;
Increment
and Decrement Operators:
Prefix
Increment Operation :
int x = 2;
int y = ++x; // x == 3, y == 3
Postfix
Increment Operation :
int x = 2;
int y = x++; // x == 3, y == 2
if Statement :
if ( Expression )
Statement;
if else Statement :
if ( Expression )
Statement1;
else
Statement2;
Switch Statement :
switch (k)
{
case 0: System.out.println ("zero"); break;
case 1: System.out.println ("one"); break;
default: System.out.println ("out of range"); break;
}
while Statement :
while ( Expression )
Statement;
do Statement :
do
Statement
while ( Expression );
for Statement :
for ( Init; Expression; Update )
Statement;
No comments:
Post a Comment