Java Conditional (branch) Statements

The "if" statement syntax
Java
NetRexx
 
if (condition) statement;
  [else statement; ]
 
if expression then statement
  [else statement  ]

Java examples:

if ( i > 10 ) i = 1 ;

if ( i != j ) k = i * j ;
   else k = 2 * i ;

if ( i!= j ) { int temp = i;
                i = j;
                j = temp; }
 

NetRexx examples:

if answer = 'yes' then say 'OK.'

if index \= 0 then index = index -1
                    else index = 99

if count = 20 then do
        say 'count has reached maximum'
        count = 1
        end
 

There are also more sophisticated conditionals such as "switch/case" statements in Java or "select/when" in NetRexx.