1
- #LyX 2.2 created this file. For more info see http://www.lyx.org/
2
- \lyxformat 508
1
+ #LyX 2.3 created this file. For more info see http://www.lyx.org/
2
+ \lyxformat 544
3
3
\begin_document
4
4
\begin_header
5
5
\save_transient_properties true
@@ -36,6 +36,8 @@ PackageOptions url hyphens
36
36
\font_osf false
37
37
\font_sf_scale 100 100
38
38
\font_tt_scale 100 100
39
+ \use_microtype false
40
+ \use_dash_ligatures false
39
41
\graphics default
40
42
\default_output_format pdf4
41
43
\output_sync 0
@@ -75,6 +77,7 @@ PackageOptions url hyphens
75
77
\suppress_date false
76
78
\justification true
77
79
\use_refstyle 1
80
+ \use_minted 0
78
81
\boxbgcolor #d8daeb
79
82
\index Index
80
83
\shortcut idx
@@ -84,7 +87,10 @@ PackageOptions url hyphens
84
87
\tocdepth 2
85
88
\paragraph_separation indent
86
89
\paragraph_indentation default
87
- \quotes_language english
90
+ \is_math_indent 0
91
+ \math_numbering_side default
92
+ \quotes_style english
93
+ \dynamic_quotes 0
88
94
\papercolumns 1
89
95
\papersides 2
90
96
\paperpagestyle default
@@ -1326,6 +1332,7 @@ status open
1326
1332
\begin_inset CommandInset citation
1327
1333
LatexCommand cite
1328
1334
key "jvm-se8-specification"
1335
+ literal "true"
1329
1336
1330
1337
\end_inset
1331
1338
@@ -2143,6 +2150,30 @@ status open
2143
2150
除了通过构造方法设置对象的初始状态外,也可以通过以下的方式进行对象的初始化操作:
2144
2151
\end_layout
2145
2152
2153
+ \begin_layout Itemize
2154
+ 定义属性的同时初始化,比如
2155
+ \begin_inset Flex Code
2156
+ status open
2157
+
2158
+ \begin_layout Plain Layout
2159
+ Circle
2160
+ \end_layout
2161
+
2162
+ \end_inset
2163
+
2164
+ 类中
2165
+ \begin_inset Flex Code
2166
+ status open
2167
+
2168
+ \begin_layout Plain Layout
2169
+ Point
2170
+ \end_layout
2171
+
2172
+ \end_inset
2173
+
2174
+ 对象的处理方式。
2175
+ \end_layout
2176
+
2146
2177
\begin_layout Itemize
2147
2178
在创建对象后,直接访问对象的属性并设置希望的值。
2148
2179
\end_layout
@@ -2157,7 +2188,7 @@ status open
2157
2188
2158
2189
\begin_layout Standard
2159
2190
\begin_inset Flex Tip
2160
- status open
2191
+ status collapsed
2161
2192
2162
2193
\begin_layout Plain Layout
2163
2194
定义有参构造方法时,要注意参数的个数不要太多,一般不要超过10个。太多的参数往往给使用者带来记忆和匹配的负担。如果需要大量的对象初始化操作,建议编写专门的方法初
@@ -2167,6 +2198,112 @@ status open
2167
2198
\end_inset
2168
2199
2169
2200
2201
+ \end_layout
2202
+
2203
+ \begin_layout Standard
2204
+ \begin_inset Flex Tip
2205
+ status open
2206
+
2207
+ \begin_layout Plain Layout
2208
+ 对象属性的初始化一般有两种方式:定义的时候直接初始化和使用构造方法。在
2209
+ \begin_inset ERT
2210
+ status open
2211
+
2212
+ \begin_layout Plain Layout
2213
+
2214
+
2215
+ \backslash
2216
+ lstlistingname
2217
+ \end_layout
2218
+
2219
+ \end_inset
2220
+
2221
+
2222
+ \begin_inset CommandInset ref
2223
+ LatexCommand ref
2224
+ reference "sub322-Circle.java"
2225
+ plural "false"
2226
+ caps "false"
2227
+ noprefix "false"
2228
+
2229
+ \end_inset
2230
+
2231
+ 中采用了直接初始化
2232
+ \begin_inset Flex Code
2233
+ status open
2234
+
2235
+ \begin_layout Plain Layout
2236
+ point
2237
+ \end_layout
2238
+
2239
+ \end_inset
2240
+
2241
+ 属性的方式,如果要使用构造方法初始化point属性,则
2242
+ \begin_inset Flex Code
2243
+ status open
2244
+
2245
+ \begin_layout Plain Layout
2246
+ Circle
2247
+ \end_layout
2248
+
2249
+ \end_inset
2250
+
2251
+ 类的定义大致为:
2252
+ \end_layout
2253
+
2254
+ \begin_layout Plain Layout
2255
+ \begin_inset listings
2256
+ inline false
2257
+ status open
2258
+
2259
+ \begin_layout Plain Layout
2260
+
2261
+ public class Circle{
2262
+ \end_layout
2263
+
2264
+ \begin_layout Plain Layout
2265
+
2266
+ Point origin;
2267
+ \end_layout
2268
+
2269
+ \begin_layout Plain Layout
2270
+
2271
+ ...
2272
+ \end_layout
2273
+
2274
+ \begin_layout Plain Layout
2275
+
2276
+ public Circle(){
2277
+ \end_layout
2278
+
2279
+ \begin_layout Plain Layout
2280
+
2281
+ origin = new Point();
2282
+ \end_layout
2283
+
2284
+ \begin_layout Plain Layout
2285
+
2286
+ }
2287
+ \end_layout
2288
+
2289
+ \begin_layout Plain Layout
2290
+
2291
+ ...
2292
+ \end_layout
2293
+
2294
+ \begin_layout Plain Layout
2295
+
2296
+ }
2297
+ \end_layout
2298
+
2299
+ \end_inset
2300
+
2301
+
2302
+ \end_layout
2303
+
2304
+ \end_inset
2305
+
2306
+
2170
2307
\end_layout
2171
2308
2172
2309
\begin_layout Exercise
@@ -5190,13 +5327,15 @@ public class Client {
5190
5327
\begin_inset CommandInset citation
5191
5328
LatexCommand cite
5192
5329
key "design-pattern-4gangs"
5330
+ literal "true"
5193
5331
5194
5332
\end_inset
5195
5333
5196
5334
、单例模式
5197
5335
\begin_inset CommandInset citation
5198
5336
LatexCommand cite
5199
5337
key "design-pattern-4gangs"
5338
+ literal "true"
5200
5339
5201
5340
\end_inset
5202
5341
@@ -7461,6 +7600,7 @@ JDK源代码可以从
7461
7600
LatexCommand href
7462
7601
name "https://github.com/dmlloyd/openjdk"
7463
7602
target "https://github.com/dmlloyd/openjdk"
7603
+ literal "false"
7464
7604
7465
7605
\end_inset
7466
7606
@@ -8816,6 +8956,7 @@ pier继承下来一样。SmartPrinter类其实是一个Facade类
8816
8956
\begin_inset CommandInset citation
8817
8957
LatexCommand cite
8818
8958
key "design-pattern-4gangs"
8959
+ literal "true"
8819
8960
8820
8961
\end_inset
8821
8962
0 commit comments