Primer:if ( boolean-expression ) { statements; } [ else { statements; } ]
class test { public static void main(String argv[]) { int starost=10; if (starost < 18) { System.out.println("Majhen si..."); System.out.println("Moras se malo zrasti"); } else System.out.println("Ti si pa velik"); } }
Primer:switch ( int-value ) { case int-value1: break; case int-value2: break; default: }
class test { public static void main(String argv[]) { int num=10; switch (num) { case 1: System.out.println("one"); break; case 2: System.out.println("two"); break; default: System.out.println("many"); } } }