a = 8 / 4;
b = 8 / 3;
c = 8 / 2;
System.out.println("Isi variabel a: " + a);
System.out.println("Isi variabel b: " + b);
System.out.println("Isi variabel c: " + c);
}
}
Operator Unari (Unary)
Contoh:
public class belajarOperatorUnary
public static void main(String[]args){{
int a = 10;
int b = 10;
boolean c= true;
int hasilA=a++;
int hasilB=++b;
boolean hasilc= !c;
System.out.println(hasilA);
System.out.println(hasilB);
System.out.println(hasilC);
}}
Operator Relasional
class BelajarJava {
public static void main(String args[]){
boolean hasil;
Operator Logika
class BelajarJava {
public static void main(String args[]){
boolean hasil;
}
}
Operator Tenary
Contoh:
Int time = 20;
If (time , 18){
System.out.println(“Good Day”);
}elsa {
System.out.println(“Good Evening”);
}
Prioritas Operator
Contoh:
Class precedence{
Public static void main (String) args {
Int a = 10, b = 5, c = 1, result;
Result = a-++c-++b;
System.out.println(result);.
}
}