1 / 23

# Assignment Operator

Assignment Operator. int a, b, c; a = b = c = 5; System.out.println ( a + b + c );. Does it compile?. Assignment Operator. int a, b, c; a = b = c = 5; System.out.println ( a + b + c );. What is the output?. Assignment Operator. int a, b, c; a = b = c = 5;

Télécharger la présentation

## Assignment Operator

E N D

### Presentation Transcript

1. Assignment Operator int a, b, c; a = b = c = 5; System.out.println( a + b + c ); Does it compile?

2. Assignment Operator int a, b, c; a = b = c = 5; System.out.println( a + b + c ); What is the output?

3. Assignment Operator int a, b, c; a = b = c = 5; System.out.println( a + b + c ); Output File Edit WindowHelp 15

4. Assignment Operator int a, b, c; a = b = c = 5; System.out.println( a + b + c ); right associative

5. Relational Operators관계 연산자 <, <=, >, >= 결과가 true / false evaluates to true / false

6. Relational Operators int a = 1; boolean b = a < 2; value of b: true

7. Relational Operators int a = 1; boolean b = a < 0; value of b: false

8. Relational Operators int a = 1; boolean b = a <= 1; value of b: true

9. Relational Operators int a = 1; int b = 2; int c = 3; boolean b = a < b < c; Does it compile?

10. Relational Operators a < b < c left associative

11. Relational Operators true < c ?

12. Relational Operators int a = 1; int b = 2; int c = 3; boolean b = a < b &b< c;

13. Boolean Logical Operators논리 연산자 !, ^, &, | 결과가 true / false evaluates to true / false

14. ! – NOT (logical complement) boolean b; 1: b = ! true; 2: b = ! (5 > 2); in 1 and 2, value of b is ‘false’

15. | - OR (inclusive or) one or the other (or both) are true

16. | - OR (inclusive or) boolean b; 1: b = true | false; 2: b = false | true; 3: b = true | true; 4: b = false | false; true true true false

17. ^ - XOR (exclusive or) One or the other, but not both, are true

18. ^ - XOR (exclusive or) boolean b; 1: b = true ^ false; 2: b = false ^ true; 3: b = true ^ true; 4: b = false ^ false; true true false false

19. & - AND both are true

20. & - AND boolean b; 1: b = true & false; 2: b = false & true; 3: b = true & true; 4: b = false & false; false false true false

21. & - AND boolean a = false; int i = 0; boolean b = a & i++ > 0; System.out.print( b + “ “ + i); Output File Edit WindowHelp false 1

22. &&, || - shortcut operators단락 연산자 boolean a = false; int i = 0; boolean b = a &&i++ > 0; System.out.print( b + “ “ + i); Output File Edit WindowHelp false 0

23. &&, || - shortcut operators boolean a = true; int i = 0; boolean b = a ||i++ > 0; System.out.print( b + “ “ + i); Output File Edit WindowHelp true 0

More Related