![](/user_photo/1549_7W_y5.jpg)
ООПИС Конспект(слайды) лекций 2007
.pdf![](/html/1549/349/html_NspOjnR3Bv.yrhO/htmlconvd-IGV4pd51x1.jpg)
%
•% *
–K
–% LM
–I (
•N *
–' I
(
–N ' '
–O
•P * I )
T )
T ) =T >*
• U % ) R (
•N R
•O ' )
•V ) W
•" R D
|
# |
$ |
|||
|
|
% |
|||
|
|
|
|||
& |
& |
& |
|||
|
|
|
|
|
|
|
|
|
|
% |
' |
|
|
|
|
|
|
|
|
|
|
|
|
D
•
'
(
Q
N R I (
•N *
–Q ! #
–O
–Q
=X W >*
• Y R
•% Z
•N ' ' Y
•% [ *
–"
–" )
–&
–Q
•\ *
•N
Q"
18.06.2007
P
•S I I
•O
•% (
•I
I
'
•D
–T )
2
![](/html/1549/349/html_NspOjnR3Bv.yrhO/htmlconvd-IGV4pd52x1.jpg)
+ I J
* K
- -4/ K
+ L
M4 NO P L
4/-)-MQ+ I JQPK
R
R
18.06.2007
789: 9; <=:>8<; |
|
|
?=:>@A< < <AB>8C9D<< |
|
|
• |
%* %) |
|
|
* EFF-)-F F # F ) F |
|
|
|
|
|
!" # |
|
• |
GH G ) |
|
|
||
$%& ' |
|
|
* EFF-)-F F3F F |
( ) * + ,-. |
|
|
|
James Gosling Circa 1971 |
|
|
|
* / ) ) 0 -%* |
|
|
|
- |
|
|
|
1-2 |
|
|
|
)-3 245 36 |
|
|
|
James Gosling Today |
|
|
|
|
|
|
|
SA9:>C<; |
|
SA9:>C<; |
|
|
|
1
![](/html/1549/349/html_NspOjnR3Bv.yrhO/htmlconvd-IGV4pd53x1.jpg)
SA9:>C<; |
|
SA9:>C<; |
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!" #$ |
|
|
% & ' |
('$ |
|
|
) * ) |
|
|
|
+, |
|
|
|
!-./$#-./$('-/$ |
|
|
|
0 |
|
|
|
) 1 |
|
|
|
& 2 ' ('+ '3 (', |
|
|
|
4 + |
'3 (' 5-6, |
|
|
|
('- '3 ('$ |
|
|
0 |
|
|
|
0 |
|
|
|
7' ('+, %' % ('$0 |
|
|
|
0 |
|
|
|
|
|
18.06.2007
TU >CUAVWUC X <A=:8WCUA:98<X
•Y Y) $ ) M - - P-
•YZ 5 M - - P M ) P-
•4) ( Y M - - P M ) P-
•GHI 0 I & < >C9AVA9; =:8> 9-
[9 >\ U \U]<
•7>CCUA:98<< \ ^8>_89CCU A9 ` 9A9a>_<@A> b-
•c<:U89a ` 9 \ b-
•def;\aUA<; ^U8UCUAA g ` 9 \ bI A> aW@hU-
•i<^ V9AA g-
•dea9=:< \<V<C>=:< <CUA-
•7>A=:9A: I <CUA>\9A<U >A=:9A:I <=^>aj >\9A<U =<C\>a<@U= <g <CUA \CU=:> a<:U89a>\-
2
![](/html/1549/349/html_NspOjnR3Bv.yrhO/htmlconvd-IGV4pd54x1.jpg)
k8<C<:<\A U :<^ V9AA g
•/ I 1 e<:E l 21-- 2m
•* I l321 e<:E
•!" " " !" " "
•"
#$%" %$#$%"
%$
•&
•"
•&
•' ! (
kU8UCUAA U
•kU8UCUAA U >efU :9 M9:8<eW: P
•kU8UCUAA U a9==9 M=:9:<@U= <U 9:8<eW: P
•c> 9ajA U ^U8UCUAA U
•k989CU:8 CU:>V>\
18.06.2007
kU8UCUAA U 2
public class TemperatureSensor { private int temperature; private static int totalMax;
public void refresh(int value) { totalMax = (value > totalMax)
? value
: totalMax; temperature = value; /* or:
this.temperature = value; */
}
kU8UCUAA U n
•o C>pA> >ef;\a;:j ^U8UCUAA U \ aqe>C CU=:U ea> 9I A> V> <=^>aj >\9A<;-
•def;\a;X:U ^U8UCUAA U 9 C>pA> ea<pU
:>@ U <g <=^>aj >\9A<;-
•?A<D<9a< <8WX:U ^U8UCUAA U ^8< >ef;\aUA<<-
•rUa9X:U \8UC; p< A< ^U8UCUAA g 9 C>pA>>8>@U-
kU8UCUAA U s
•?=^>aj WX:U 9pVWq ^U8UCUAAWq :>aj > = >VA>X DUajq-
•?C; ^U8UCUAA>X V>apA> :>@A> < ^>aA> >^<= \9:j =W]A>=:jI ^8UV=:9\a;UCWq ^U8UCUAA>X-
•?CUAWX:U <AVU = D< a>\ I I #-
•E ^8< <=^>aj >\9A<< =a>pA g V9AA gI A9^8<CU8I CA>_>CU8A g C9==<\>\ V9\9X:U =>VU8p9:UajA U <CUA9 <AVU =9C
d^U89:>8
• |
" |
• |
|
• |
' |
• |
' uuI ' ll |
• |
) / |
• |
uu ' I ll ' I u ' I |
|
|
|
l ' I vI J |
• |
) |
• |
wI FI x |
• |
|
• |
uI l |
• |
* |
• |
yyI zzI zzz |
• |
|
• |
yI zI y{I z{I |
• |
t) / |
|
|
• |
|
||
|
|
{{I J{ |
3
![](/html/1549/349/html_NspOjnR3Bv.yrhO/htmlconvd-IGV4pd55x1.jpg)
d^U89:>8 2
• |
0(G |
• |
} |
• ' ) "| |
• |
~ |
|
• ) "| |
• |
• |
|
• |
0(G |
• |
}} |
• |
"| |
• |
•• |
• |
|
• |
€ E |
• |
|
• {I u{I l{I w{I F{I x{I |
|
|
|
|
}{I ~{I •{I yy{I zz{I |
|
|
|
zz{ |
b>\U:
•T9 CU]9X:U A>8C9ajA X \98<9A: ^>\UVUA<; ^8>_89CC ^>=aU I 9 AU ^>=aU -
•?=^>aj WX:U W= >8UAA>U \ @<=aUA<U a>_<@U= <g \ 89pUA<X-
•T9 CU]9X:U A9<e>aUU \U8>;:A U \98<9A: 89AjhU >=:9ajA g-
•b:989X:U=j 9\U8h9:j 9pV X >^U89:>8>C
#- d=:U8U_9X:U=j = \> A g -
d^U89:>8
if (< )
< >
else
< >
•< a
while (< . .>) < >
do
< > while (< . .>);
for ( 1; 2; 3) < >
18.06.2007
d^U89:>8 *
switch (< >) { case < . >:
< > break;
...
case < . >: < > break;
default: < >
}
k8<CU8
isEmpty = false; while (isEmpty) {
isEmpty = refreshElements();
}
do {
isEmpty = refreshElements(); } while (isEmpty);
4
![](/html/1549/349/html_NspOjnR3Bv.yrhO/htmlconvd-IGV4pd56x1.jpg)
k8<CU8 2
int S = 0;
for (int i = 0; i < 10; i++) { S += i * i;
}
b>\U:
•T9 CU]9X:U <A<D<9a< 9D<>AA X >V AU^>=8UV=:\UAA> ^U8UV D< a>C
•?=^>aj WX:U * M ) P Va; >8_9A< 9D<< eU= >AU@A>_> D< a9-
•k8UV^>@<:9X:U D< a -
•? eU_9X:U ^W=: g D< a>\-
•T9=^>a9_9X:U =aWpUeA U >^U89D<< a<e> \ A9@9aUI a<e> \ >ADU D< a9-
#I )
while (true) {
if (somethingGood) {
break;
} else {
continue;
}
b>\U: 2
•?=^>aj WX:U =C =a>\ U <CUA9 ^U8UCUAA g \ D< a9gI @:>e =VUa9:j \a>pUAA U D< a e>aUU @<:9eUajA C< < @:>e AU >h<e9:j=; = <AVU =9C< ^8< <=^>aj >\9A<< C9==<\>\-
•d_89A<@<\9X:U \<V<C>=:j ^U8UCUAA gl<AVU =>\ D< a9 =9C<C D< a>C-
•‚U VUa9X:U :Ua> D< a9 Va<AA>X e>aUU >VA>_> ƒ 89A9-
•d_89A<@<\9X:U \a>pUAA>=:j :8UC; W8>\A;C<-
•?=^>aj WX:U >^U89:>8 # \CU=:> a>_<@U= <g Ba9_>\ 9\U8hUA<;-
18.06.2007
•ba>\> 98U U8\<8>\9A>
•d^U89:>89 AU:
•‚> U=:j >^U89:>8 #E
–while (myCondition) {
–if (somethingGood) {
–break exit;
–}
–}
–exit:
d=:9ajA>U
•k8>DUVW8 < BWA D<<-
•d^U89:>8 ) -
•+ „ J = ^989CU:89C< >C9AVA>X =:8> <-
•b:9AV98:A U VU= 8<^:>8 I ) I -
•b:8> < ` AU =>\=UC 9 \ b- - -4
•…9==<\ ` AU =>\=UC 9 \ b-
5
![](/html/1549/349/html_NspOjnR3Bv.yrhO/htmlconvd-IGV4pd57x1.jpg)
8 9 : ; <= )
>#?
@'$ >#? +, @'-/$ 0
0
:" ) <*1 ) )A <= )
>#? @# B'$
C 91 <= ) ; 9 ; <= )
@# B'- '3 >#? +,$
D1 <= ) E 7 % 7' ' %" 4 ('
F . G
|
|
|
(Optional) Access level for the variable |
||
|
|||
|
|
|
|
|
(Optional) Declares a class variable |
||
|
|||
|
|
|
|
|
(Optional) Indicates that the variable is a constant |
||
|
|
|
|
|
|
||
|
|
4 @#H %$
18.06.2007
) 1 G . G
Element |
Function |
|
(Optional) Access level |
||
|
|||
|
|
|
|
|
(Optional) Declares a class method |
||
|
|||
|
|
|
|
|
(Optional) Indicates that the method is not implemented |
||
! |
|||
|
|
|
|
$ |
(Optional) Indicates that the method cannot be overridden |
||
#" |
' >'+ @',
I J@'-@'$
%' % I J@'$
0
K ) A 1 )*
|
Specifier |
Class |
Package |
Subclass |
World |
|
|
|
|
|
|
( ' & % |
Y |
N |
N |
N |
|
|
|
|
|
|
|
|
no specifier |
Y |
Y |
N |
N |
|
|
|
|
|
|
* |
Y |
Y |
Y |
N |
|
( () & % |
|||||
|
|
|
|
|
|
, |
Y |
Y |
Y |
Y |
|
+ % |
|||||
|
|
|
|
|
|
C) ) |
|
1 G |
) 0† L |
|
) 0 L |
|
|
|
) { ‡K |
|
) MP L |
|
|
|
) Z * MP L |
|
4/-)-MQ 0-QPK |
|
|
|
) K |
|
R |
|
|
|
R |
|
R |
|
|
|
) { ‡K |
|
) † ' 0 L |
|
|
|
) Z * MP L |
|
) MP L |
|
|
|
) K |
|
4/-)-MQ †-QPK |
R |
|
R |
R |
|
R |
|
|
|
6
![](/html/1549/349/html_NspOjnR3Bv.yrhO/htmlconvd-IGV4pd58x1.jpg)
18.06.2007
L A9 G '% 1 G |
|
) M : G |
|
A9 G ) M : G |
|
|
|
||
) 4) ' 4) L |
|
|
|
) 4 #„ * L |
|
|
|
|
|
FF* & 4) |
|
|
|
) †* M% # 4/ # 4/ I Y G & ) PK |
|
|
|
|
|
) & K |
|
|
|
R |
|
|
|
|
|
) Z * MP L |
|
|
|
) 4 #0. / ' L |
|
|
|
|
|
FF Z * 4) |
|
|
|
) ) †* M% # 4/ # 4/ I Y G |
|
|
|
|
|
& { K |
|
|
|
& ) P L |
) ' *+, |
|
|
|
* M # 4/ P L |
4/-)-M & PK |
|
|
|
4ˆ(„E---#K |
4/-)-M - PK |
|
|
|
†4†"E---#K |
R |
|
|
|
) E---#K |
R |
|
|
|
R |
|
|
|
|
R |
|
|
|
|
R |
|
|
|
|
|
) " M :
# )-)- -#- -K
-t-† K
-)-0 /‰ K
-)-‰ K
-#- -)-G 4 ) ˆ K
) 0 G0" L
G 4 ) 4 ) K
) 0 M P * 4Š‰5' L † { G 4 ) ˆ-† M 4 ) PK
6
z )F )F F #F F F 0 G0"-
7
![](/html/1549/349/html_NspOjnR3Bv.yrhO/htmlconvd-IGV4pd59x1.jpg)
•-. /0
•1 2 /0
•-
Test p = (Test)t;
• )3'( 3*456
•!
–Node n1;
–Node n1 = null;
–Node n1 = new Node();
& & #
•7 # . #- % +
•8 # & & 99 :; #-
. -# % & 0 +
•, # & & &
–&
•, 2 & &
–#
18.06.2007
" # "
•$#
•# !
•$# " # " % & # '( ()*+
class Test {
private int x, y, z = 6;
{
x = 4;
y = Math.max(x, z);
}
}
,& # #
< = & & #
1.class Test {
2.private Test t;
3.private Test tt = new Test();
4.public void f() {
5.new Test();
6.t = new Test();
7.Test ttt = t;
8.t = ff(ttt)
9.}
10.public Test ff(Test t) {
11.return t;
12.}
13.}
1
![](/html/1549/349/html_NspOjnR3Bv.yrhO/htmlconvd-IGV4pd60x1.jpg)
-
•> ?- -
•# ; ?-
#
protected void finalize() throws Throwable {
super.finalize();
// ...
}
= R !
•>
•7 ! # # #-
R !
•= R ! . ! R !
@
•?-.
–; ?-
•#
–A-# B
–! #
•# " ?-!
protected void finalize() throws Throwable { … protected void ff() throws Throwable,IOException { …
S # # "
class Test2 extends Test1 implements Task1, Task2 {
}
interface Task1 {
}
interface Task2 extends Task {
}
18.06.2007
7 #/& !
•(CD E F G * (*H %IJ*4K()53 4+ E F G 6)3 LLD E F G
•M ! # IJ*4K()53
•M# 6)3 LLD
•N 4<KC)3(O( *PQC *4%+
M ! # TUV4*(
W< KC5(4*(4X TUV4*( *L534%+< U55L4 3 4YZ L'%TUV4*( 5UV+ [< KC5(4*(4X 5)X 6)3 L)\4%+ ]< ^L ''_`a b4(^L ''%+
c< )3( H 'H^5X4%+ d< 5)X 35()6D%+ e< 5)X 35()6DfLL%+
g< O(C)3b (5O(C)3b%+ h< 5)X i )(%+
W:< 5)X i )(%L53b ()j45Z(+
WW< 5)X i )(%L53b ()j45Z(; )3( 3 35'+
2