Operātori
If operators
Sintakse:
if (boolean-expression)
statement-1
else
statement-2
Switch operators:
Vairākās programmēšanas valodās tiek izmantots operators case, taču valodā JAVA case funkcijas pilda operators switch.
switch (expression) {
case constant-1:
statements-1
break;
case constant-2:
statements-2
break;
.
. /*vairāki case operatori*/
.
case constant-N:
statements-N
break;
default:
/*norāda kurš case operators tiks izpildīts pēc noklusēšanas*/
statements-(N+1)
For operators, izmanto cikla organizēšanai.
For (int x = 1; x<5; x++) {
System.out.println (x);
}
While operators
While un do operators valodā JAVA ir identisks ar valodas C operatoru, operatora izteiksmei obligāti ir jābūt boolean izteiksmei.
while ( boolean-expression )
statement
Do ... while operators
Šis operators veic identiskas darbības kā while operators, taču galvenā atšķirība ir tā, ka šeit boolean izteiksmes patiesuma pārbaude notiek cikla beigās nevis sākumā.
do
{ statement }
while ( boolean-expression );