Documente Academic
Documente Profesional
Documente Cultură
Cristian Frsinaru
Cuprins
1
Introducere n Java
1.1 Ce este Java ? . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2
1.3
1.4
1.5
1.6
11
11
11
12
13
14
16
16
16
17
17
19
19
20
21
21
22
24
24
25
26
26
26
26
28
28
29
CUPRINS
Transmiterea argumentelor . . . . . . . . . . . . . . . .
Primirea argumentelor . . . . . . . . . . . . . . . . . .
29
30
30
31
31
32
1.8.3
Argumente
numerice . . . . . . . . . . . . . . . . . . .
34
35
2 Obiecte si clase
2.1 Ciclul de viata al unui obiect . . . . . . . . . . . . . . . . . . .
2.2
2.3
2.4
2.5
2.6
2.7
CUPRINS
2.7.1
.............
Exceptii
35
68
68
71
71
71
74
75
77
35
37
38
39
39
40
41
42
46
49
50
50
52
53
56
57
58
59
59
61
62
63
64
64
66
66
67
67
77
3.2
3.3
3.4
78
82
85
85
87
89
90
91
92
3.5
3.6
3.7
.......
95
Intrari si iesiri
4.1 Introducere . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2
95
........
95
96
97
98
99
99
4.2.2
4.2.3
4.2.4
4.2.5
4.2.6
4.2.7
. . . . . . . . . . . . . 108
4.3.2
. . . . 109
CUPRINS
4
4.4 Fluxuri standard de intrare si iesire . . . . . . . . . . . . . . . 111
4.4.1
4.4.2
4.4.3
4.4.4
5 Interfete
5.1 Introducere . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
5.1.1 Ce este o interfata ? . . . . . . . . . . . . . . . . . . . 121
5.2 Folosirea interfetelor . . . . . . . . . . . . . . . . . . . . . . . 122
5.2.1
5.2.2
5.2.3
. . . . . . . . . . . . . . . . . . . . 134
Interfata Comparable
Interfata Comparator
. . . . . . . . . . . . . . . . . . . 139
. . . . . . . . . . . . . . . . . . . 141
6 Organizarea claselor
6.1 Pachete
6.1.1
6.1.2
6.1.3
6.1.4
6.1.5
6.1.6
6.1.7
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Pachetele standard (J2SDK) . . . . . . . . . . . . . . . 145
Folosirea membrilor unui pachet . . . . . . . . . . . . . 146
Importul unei clase sau interfete . . . . . . . . . . . . . 147
Importul la cerere dintr-un pachet . . . . . . . . . . . . 148
Importul static . . . . . . . . . . . . . . . . . . . . . . 149
Crearea unui pachet
. . . . . . . . . . . . . . . . . . . 150
Denumirea unui pachet . . . . . . . . . . . . . . . . . . 151
CUPRINS
6.2.2
6.3
Colectii
7.1 Introducere . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
7.2
7.3
7.4
7.5
7.6
. . . . . 154
161
Serializarea obiectelor
177
8.2
199
9.3
CUPRINS
9.7 Folosirea
componentelor
AWT . . . . . . . . . . . . . . .
. . . 250
9.7.1 Clasa Label
.................
. . . . . . . 251
9.7.2 Clasa
Button . . . . . . . . . . .
. . . . . . . . . . . . 252
9.7.3 Clasa Checkbox . . . . . . . . . . . . . . . . . . . . . . 253
9.7.4 Clasa CheckboxGroup . . . . . . . . . . . . . . . . . . 255
9.7.5
Clasa Choice
9.7.6
9.7.7
. . . . . . . . . . . . . . . . . . . . . . . 257
9.7.8
Clasa ScrollPane
9.7.9
. . . . . . . . . . . . . . . . . . . . . 262
10 Desenarea
10.1 Conceptul de desenare . . . . . . . . . . . . . . . . . . . . . . 269
10.1.1 Metoda paint . . . . . . . . . . . . . . . . . . . . . . . 270
10.1.2 Suprafete de desenare - clasa Canvas . . . . . . . . . . 271
10.2 Contextul grac de desenare . . . . . . . . . . . . . . . . . . . 274
10.2.1 Proprietatile contextului grac . . . . . . . . . . . . . . 275
CUPRINS
. . . . . . . . . . . . . . . . . . . . . 275
299
11.6.7 Dialoguri
. . . . . . . . . . . . . . . . . . . . . . . . . 335
11.7 Desenarea . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
11.7.1 Metode specice
. . . . . . . . . . . . . . . . . . . . . 336
11.7.2 Consideratii generale . . . . . . . . . . . . . . . . . . . 338
11.8 Look and Feel . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
CUPRINS
8
12 Fire de executie
343
383
14 Appleturi
401
. . . . . . . . . . . . . . . . . . . . . . . . . 410
CUPRINS
15 Lucrul cu baze de date
423
15.1 Introducere . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
15.1.1 Generalitati despre baze de date . . . . . . . . . . . . . 423
15.1.2 JDBC . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
15.2 Conectarea la o baza de date . . . . . . . . . . . . . . . . . . . 425
15.2.1 Inregistrarea unui driver . . . . . . . . . . . . . . . . . 426
15.2.2 Specicarea unei baze de date . . . . . . . . . . . . . . 427
15.2.3 Tipuri de drivere . . . . . . . . . . . . . . . . . . . . . 428
15.2.4 Realizarea unei conexiuni
. . . . . . . . . . . . . . . . 430
15.3 Efectuarea de secvente SQL . . . . . . . . . . . . . . . . . . . 431
15.3.1 Interfata Statement . . . . . . . . . . . . . . . . . . . . 432
15.3.2 Interfata PreparedStatement . . . . . . . . . . . . . . . 434
15.3.3 Interfata CallableStatement . . . . . . . . . . . . . . . 437
15.3.4 Obtinerea si prelucrarea rezultatelor
. . . . . . . . . . 438
15.3.5 Interfata ResultSet . . . . . . . . . . . . . . . . . . . . 438
15.3.6 Exemplu simplu . . . . . . . . . . . . . . . . . . . . . . 440
15.4 Lucrul cu meta-date
. . . . . . . . . . . . . . . . . . . . . . . 442
15.4.1 Interfata DatabaseMetaData . . . . . . . . . . . . . . . 442
15.4.2 Interfata ResultSetMetaData
. . . . . . . . . . . . . . 443
16 Lucrul dinamic cu clase
445
16.1 Incarcarea claselor n memorie . . . . . . . . . . . . . . . . . . 445
16.2
Mecanismul
reectarii
...........
...........
452
16.2.1
Examin
area
claselor
si
interfet
elor . . .
.......
. . 453
16.2.2
Manipu
larea
obiectel
or . . . .
.......
.......
456
16.2.3
Lucrul
dinamic
cu
vectori
.......
.......
..4