– if ( c >= ‘A’ && c <= ‘Z’) (statement)
• If c is from A to Z, (statement) is executed.
– if ( ! ( c >= ‘A’ && c <= ‘Z’)) (statement)
• If c is not form A to Z, (statement) is executed.
– while ( i < 0 || i > 50 ) (statement)
• If i < 0 or i > 50, (statement) is executed.
i:2 j :3
i/j : 0
(float)i/j : 0.6666667
(float)(i/j) : 0.0
(int)3.789 : 3
(char)65.789 : A
– Arithmetic Assignment
+ =
– =
* =
/ =
% =
– Bit Assignment
<< = (shift a bit pattern to the left)
>> = (shift a bit pattern to the right)
| = (bit OR) & = (bit AND) ^ = (bit XOR)
i:2 j :3
i/j : 0
(float)i/j : 0.6666667
(float)(i/j) : 0.0
(int)3.789 : 3
(char)65.789 : A
i:2 j :3
(float)i/j : 0.6666667
(float)(i/j) : 0.0
– op1 & op2
• The AND operator compares two bits and generates a result of 1 if both bits are 1; otherwise, it returns 0.
– op1 | op2
• The OR operator compares two bits and generates a result of 1 if the bits are complementary; otherwise, it returns 0.
– op1^ op2
• The EXCLUSIVE-OR operator compares two bits and generates a result of 1 if either or both bits are 1; otherwise, it returns 0.
– ~op1
• The COMPLEMENT operator is used to invert all of the bits of the operand.
– op1 >> op2
• The SHIFT RIGHT operator moves the bits to the right, discards the far right bit, and assigns the leftmost bit a value of 0. Each move to the right effectively divides op1 in half.
– op1 << op2
• The SHIFT LEFT operator moves the bits to the left, discards the far left bit, and assigns the rightmost bit a value of 0. Each move to the left effectively multiplies op1 by 2.
(+) 16진수
16진법은 0~9까는 아라비아 숫자와 똑같이 표기하지만,10 부터는 알파벳을 이용한다.
10 = A,11 = B,12 = C ... 15 = F
a : a7
a & F0 : a0
a | F0 : f7
a ^ F0 : 57
x:2 y:5 z:8
x / y * z : 0
x = y += z : 13
– char type can be used integer type.
– boolean equals(Object other)
– must have type : int, long, short, double, float, char, String, boolean, byte, ...
– must have value (assignment before use it)
– name must follow the rules
• (1) Only alphabet, number, under-score _ usable
• (2) cannot start with number
• (3) upper and lower cases must be distinguished
• (4) reserved word (if, while, int, long, …) cannot be used as the variable name
– array name, class name, method name follow the same rule as the variable name
– class variable must be declared within the scope : local or global variables
– Int n = ‘K’ + ‘M’ + ‘J’ ;
• 75 + 77 + 74 = 226
• n =226
b : -96
s : -31072
int boolean String
int double boolean String
0 0.0 false null
0 0.0 false null
100 1.23 true Java JaBa
< ArrayIndexOutOfBoundsException 컴파일 에러가 못~ 잡아>
11 105
21 205
31 305
41 405
51 505
0 0
0 0
0 0
0 0
0 0
Exception in thread "main"
java.lang.ArrayIndexOutOfBoundsException:
Index 10 out of bounds for length 10
at lec.op.main(op.java:21)
(System.out.println(a[i] + " " + b[i]); )
1 1
3 3
5 5
7 7
9 9
11 0
13 0
15 13
17 15
19 17
21 0
23 0
111 111
222 222
333 333
444 444
555 555
30 52 89 16 52 43 20 13 28 90
<random number count>
10~19 : 2
20~29 : 2
30~39 : 1
40~49 : 1
50~59 : 2
60~69 : 0
70~79 : 0
80~89 : 1
90~99 : 1