forked from GoodVibes833/Java_basic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnote_java
99 lines (61 loc) · 1.6 KB
/
note_java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
1. compile
- javac XXX.java -> compile -> hexa(bytecode), nema.class
- java XXX : excute file
2. data type
1) Primitive : store data(value) into memory
- byte(1bytes = 8bits = 8 slots) _ _ _ _ _ _ _ _ (binary ) decimal x
- short(2bytes)
-* int(4bytes)
- long(8, 64 bit)
-* char(a character, 1 byte)
- float(10.2f 32bit)
-* double(10.24 64bits) - more precise
-* boolean( )
# 2^0 + ...+ 2^n = 2^(n+1)-1
# minus
8bit -> use only 7bit.
first bit : 1 --> -
first bit : 0 --> +
01111111 : 127
10000000 : -128
11111111 : -1
10000001
2) Reference : store reference(location)
3. run or import
1) run
- have to have MAIN function
2) import
-
4. JVM
(bytecode)
.Java -> .class ->
compile JVM(SW)
5. errors
1) Compile -time error : red underline
- syntax,
2) Run-time error : after run your program, hard to fix
6. conditional statements
- if - else <-- JS
- swich - case
7. loops : for, while
- break : stop
- continue : skip
8. operator
+ - * / % ++ --
&& || !
---------------------------------------------------------------------------------
1. Object Oriented
class Car
1) state(attributes) -> variables color, doors, type
2) behaviors(Action) -> methods drive(), park(), break()
class---
| |-> car1(object, instance) : has different 1),2)
|Car |-> car2
---------
blueprint(declear)
- constructor is a method to create instance : initialize variables
- Car myCar = new Car(1,1,1,1)
type var = new constructor
- instances
: self contained code, variable, object
: New custom data type