Presentation is loading. Please wait.

Presentation is loading. Please wait.

OPERATOR Dalam Java.

Similar presentations


Presentation on theme: "OPERATOR Dalam Java."— Presentation transcript:

1 OPERATOR Dalam Java

2 Computes the remainder of dividing op1 by op2
Operator Aritmatika Operator Use Description + op1 + op2 Adds op1 and op2 * op1 *op2 Multiplies op1 by op2 / op1 / op2 Divides op1 by op2 % op1 % op2 Computes the remainder of dividing op1 by op2 - op1 - op2 Subtracts op2 from op1

3 Operator Increment dan Decrement
Use Description ++ op++ Increments op by 1; evaluates to the value of op before it was incremented ++op Increments op by 1; evaluates to the value of op after it was incremented -- op-- Decrements op by 1; evaluates to the value of op before it was decremented --op Decrements op by 1; evaluates to the value of op after it was decremented

4 Contoh int i = 10, int j = 3; int k = 0;
k = ++j + i; // menghasilkan k = 4+10 = 14 k = --j + i; //menghasilkan k = 2+10 = 12 k = j++ + i; // menghasilkan k = 3+10 = 13 k = j-- + i; //menghasilkan k = 3+10 = 13

5 op1 is greater than or equal to op2 op1 is less than or equal to op2
Operator Relasi Operator Use Description > op1 > op2 op1 is greater than op2 >= op1 >= op2 op1 is greater than or equal to op2 < op1 < op2 op1 is less than op2 <= op1 <= op2 op1 is less than or equal to op2 == op1 == op2 op1 and op2 are equal != op1 != op2 op1 and op2 are not equal

6 && (logika AND) dan & (boolean logika AND)
x1 x2 Result TRUE FALSE

7 || (logika OR) | (boolean logika inclusive OR)
x1 x2 Result TRUE FALSE

8 ^ (boolean logika ExclusiveOR )
Result TRUE FALSE

9 ! (logika NOT) x1 Result TRUE FALSE

10 Operator Kondisi(?:) Struktur pernyataan yang menggunakan operator kondisi adalah, exp1 ? exp2 : exp3

11 Contoh class kondisiOperator {
public static void main( String[] args ){ int score = 0; char answer = 'a'; score = (answer == 'a') ? 10 : 0; System.out.println("Score = " + score ); }

12 Terima Kasih …. Next Structure …


Download ppt "OPERATOR Dalam Java."

Similar presentations


Ads by Google