-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
2518 lines (963 loc) · 63.5 KB
/
index.html
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html class="theme-next pisces use-motion" lang="zh-CN">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"/>
<meta name="theme-color" content="#222">
<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />
<link href="/css/main.css?v=6.3.0" rel="stylesheet" type="text/css" />
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=6.3.0">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=6.3.0">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=6.3.0">
<link rel="mask-icon" href="/images/logo.svg?v=6.3.0" color="#222">
<script type="text/javascript" id="hexo.configurations">
var NexT = window.NexT || {};
var CONFIG = {
root: '/',
scheme: 'Pisces',
version: '6.3.0',
sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
fancybox: false,
fastclick: false,
lazyload: false,
tabs: true,
motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
algolia: {
applicationID: '',
apiKey: '',
indexName: '',
hits: {"per_page":10},
labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
}
};
</script>
<meta property="og:type" content="website">
<meta property="og:title" content="Faye's Blog">
<meta property="og:url" content="http://yoursite.com/index.html">
<meta property="og:site_name" content="Faye's Blog">
<meta property="og:locale" content="zh-CN">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Faye's Blog">
<link rel="canonical" href="http://yoursite.com/"/>
<script type="text/javascript" id="page.configurations">
CONFIG.page = {
sidebar: "",
};
</script>
<title>Faye's Blog</title>
<noscript>
<style type="text/css">
.use-motion .motion-element,
.use-motion .brand,
.use-motion .menu-item,
.sidebar-inner,
.use-motion .post-block,
.use-motion .pagination,
.use-motion .comments,
.use-motion .post-header,
.use-motion .post-body,
.use-motion .collection-title { opacity: initial; }
.use-motion .logo,
.use-motion .site-title,
.use-motion .site-subtitle {
opacity: initial;
top: initial;
}
.use-motion {
.logo-line-before i { left: initial; }
.logo-line-after i { right: initial; }
}
</style>
</noscript>
</head>
<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">
<div class="container sidebar-position-left
page-home">
<div class="headband"></div>
<header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-wrapper">
<div class="site-meta ">
<div class="custom-logo-site-title">
<a href="/" class="brand" rel="start">
<span class="logo-line-before"><i></i></span>
<span class="site-title">Faye's Blog</span>
<span class="logo-line-after"><i></i></span>
</a>
</div>
</div>
<div class="site-nav-toggle">
<button aria-label="切换导航栏">
<span class="btn-bar"></span>
<span class="btn-bar"></span>
<span class="btn-bar"></span>
</button>
</div>
</div>
<nav class="site-nav">
<ul id="menu" class="menu">
<li class="menu-item menu-item-home menu-item-active">
<a href="/" rel="section">
<i class="menu-item-icon fa fa-fw fa-home"></i> <br />首页</a>
</li>
<li class="menu-item menu-item-tags">
<a href="/tags/" rel="section">
<i class="menu-item-icon fa fa-fw fa-tags"></i> <br />标签</a>
</li>
<li class="menu-item menu-item-categories">
<a href="/categories/" rel="section">
<i class="menu-item-icon fa fa-fw fa-th"></i> <br />分类</a>
</li>
<li class="menu-item menu-item-archives">
<a href="/archives/" rel="section">
<i class="menu-item-icon fa fa-fw fa-archive"></i> <br />归档</a>
</li>
</ul>
</nav>
</div>
</header>
<main id="main" class="main">
<div class="main-inner">
<div class="content-wrap">
<div id="content" class="content">
<section id="posts" class="posts-expand">
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/09/14/《人月神话》读书笔记/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Faye">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/photo.jpg">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Faye's Blog">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2019/09/14/《人月神话》读书笔记/" itemprop="url">
《人月神话》读书笔记
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2019-09-14 17:20:56" itemprop="dateCreated datePublished" datetime="2019-09-14T17:20:56+08:00">2019-09-14</time>
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-calendar-check-o"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2019-09-18 23:07:24" itemprop="dateModified" datetime="2019-09-18T23:07:24+08:00">2019-09-18</time>
</span>
<span class="post-category" >
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/读书笔记/" itemprop="url" rel="index"><span itemprop="name">读书笔记</span></a></span>
</span>
<span class="post-comments-count">
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<a href="/2019/09/14/《人月神话》读书笔记/#comments" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count"
data-disqus-identifier="2019/09/14/《人月神话》读书笔记/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p><strong>焦油坑有个特点,当身陷其中时,挣扎的越猛烈,焦油就会缠的越紧。</strong>作者将大型系统开发比作焦油坑,旨在说明大型系统开发是一项极其繁杂困难的行为,不论团队规模大小,不论团队成员能力高低,都只有很少一部分可以从焦油坑走出来,即满足开发初期目标、进度、预算等要求。 这时人们迫切想寻找一把尚方宝剑,来解决开发管理中的各种问题,但很可惜,软件的特性决定了软件开发没有银弹,本书也只是从以下几个方面给出了软件工程管理上的一些建议。</p>
<h2 id="团队构建"><a href="#团队构建" class="headerlink" title="团队构建"></a>团队构建</h2><p>优秀程序员和较差程序员在编码效率上往往存在着很大的差异,所以管理人员倾向于使用小而精的队伍进行系统开发,但随之而来产生一个问题,即使效率再高的开发队伍,面对一个十分庞大的系统开发任务时,仍然会显得力不从心。</p>
<p>作者介绍了一种类似于“外科手术队伍”的解决方案,具体是指<strong>大型项目的每一个部分由一个团队负责,而每一个团队又以外科手术的形式构建,是一种 1+N 的形式</strong>。1 的那个人是一个经验丰富的系统架构师,负责整体的架构设计,而 N 进行工作上的支持。架构师还负责决定一切有争议的事务,所有的纷争都要由他来拍板。如果在这一点上不加以限制,团队的注意力会集中于各式各样的想法和争议上,也就无法专注于实现程序的具体功能。</p>
<!--noindex-->
<div class="post-button text-center">
<a class="btn" href="/2019/09/14/《人月神话》读书笔记/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/08/08/浅谈 Session 和 Cookie/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Faye">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/photo.jpg">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Faye's Blog">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2019/08/08/浅谈 Session 和 Cookie/" itemprop="url">
浅谈 Session 和 Cookie
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2019-08-08 16:12:48" itemprop="dateCreated datePublished" datetime="2019-08-08T16:12:48+08:00">2019-08-08</time>
</span>
<span class="post-category" >
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/个人随想/" itemprop="url" rel="index"><span itemprop="name">个人随想</span></a></span>
</span>
<span class="post-comments-count">
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<a href="/2019/08/08/浅谈 Session 和 Cookie/#comments" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count"
data-disqus-identifier="2019/08/08/浅谈 Session 和 Cookie/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="为什么需要-Session-和-Cookie"><a href="#为什么需要-Session-和-Cookie" class="headerlink" title="为什么需要 Session 和 Cookie"></a>为什么需要 Session 和 Cookie</h2><p>HTTP 请求是无状态的,这也就意味着浏览器收到一个请求,只知道要做什么任务,却不知道是任务发布者是谁。举个例子,用户想要查看购物车信息,如果没有 Session,服务器就无法知道查看哪个用户的购物车,也就无法给出准确的答复。<br>Cookie 的数据保存在客户端,可通过浏览器进行查看;Session 的数据保存在服务端,相比较而言更加安全,但如果数据过多,会影响运行效率。</p>
<h2 id="Session-和-Cookie-的合作"><a href="#Session-和-Cookie-的合作" class="headerlink" title="Session 和 Cookie 的合作"></a>Session 和 Cookie 的合作</h2><p>当浏览器发出一个请求时,Session 随之建立,同时返回给浏览器的 response 中包含Set-Cookie 字段,通常该字段中会存在 session_id(sid)值。浏览器收到 response 后,会根据 Set-Cookie 字段设置 Cookie,下一次发送请求时,会自动携带该 Cookie。<br>这样,下一次服务端收到请求后,根据 sid 找到对应 Session,从而也就找到了该会话的一系列状态信息,例如当前登录的用户等等。这也就解决了 HTTP 请求无法保存状态信息的问题。如果遇到浏览器禁止 Cookie 的情况,也可将 sid 附加到 url 中。<br><em>以下为本人猜测内容,未经考证。在成熟 Web 框架,例如 SSM 中,Controller 收到请求会根据 sid 自动解析 Session,因此可以通过 request.getSession() 函数直接获取 Session 信息,而不需关心与 Session 相关的底层操作。</em></p>
<h2 id="如何实现“保持登录状态”这一功能"><a href="#如何实现“保持登录状态”这一功能" class="headerlink" title="如何实现“保持登录状态”这一功能"></a>如何实现“保持登录状态”这一功能</h2><p>有些时候,我们需要实现这样一个功能,即退出浏览器下次访问该网站时,可以自动登录,不需要重新输入用户名和密码。这一功能的实现就依赖于 Session 和 Cookie。</p>
<ul>
<li>如果只靠 Session 来实现这一功能,可以延长 Session 的过期时间。一般来说,Session 会在会话结束时过期,即关闭浏览器后 Session 就会被销毁。而在 Django 中,Session 的默认过期时间是两周,如果用户不需要保存登录状态,则要将过期时间手动设为 0,这样关闭浏览器后用户就自动注销了。</li>
<li>如果使用 Cookie 来实现这一功能,则无需延长 Session 的过期时间。当用户登录成功后,浏览器返回的 Set-Cookie 中不仅要包含基本信息,还要包含登录用户的 ID、Token 或相关信息。这样用户下一次访问该网站时,Cookie 信息会随 request 发送到服务端,服务端通过解析 Cookie 得到用户 ID 和 Token。再将 ID 和 Token 与存储在数据库中的信息进行比对,如果相符,则在 Session 中设置当前登录的用户信息,并跳转到主页面;如果不符,跳转到系统的登录页面。</li>
</ul>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/08/05/Lintcode 题解/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Faye">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/photo.jpg">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Faye's Blog">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2019/08/05/Lintcode 题解/" itemprop="url">
Lintcode 「阶梯训练——美国大公司」 题解
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2019-08-05 20:48:08" itemprop="dateCreated datePublished" datetime="2019-08-05T20:48:08+08:00">2019-08-05</time>
</span>
<span class="post-category" >
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/算法/" itemprop="url" rel="index"><span itemprop="name">算法</span></a></span>
</span>
<span class="post-comments-count">
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<a href="/2019/08/05/Lintcode 题解/#comments" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count"
data-disqus-identifier="2019/08/05/Lintcode 题解/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h3 id="String"><a href="#String" class="headerlink" title="String"></a>String</h3><ul>
<li><p>158 哈希表</p>
<blockquote>
<p>写出一个函数 <code>anagram(s, t)</code> 判断两个字符串是否可以通过改变字母的顺序变成一样的字符串。 写出一个函数 <code>anagram(s, t)</code> 判断两个字符串是否可以通过改变字母的顺序变成一样的字符串。 </p>
</blockquote>
</li>
<li><p>55 哈希表</p>
<blockquote>
<p>比较两个字符串A和B,确定A中是否包含B中所有的字符。字符串A和B中的字符都是 <strong>大写字母</strong> </p>
</blockquote>
</li>
<li><p>13 暴力查找 len1-len2</p>
<blockquote>
<p>对于一个给定的 source 字符串和一个 target 字符串,你应该在 source 字符串中找出 target 字符串出现的第一个位置(从0开始)。如果不存在,则返回 <code>-1</code>。 </p>
</blockquote>
</li>
<li><p>171 排序后的字符串作为哈希值</p>
<blockquote>
<p>给出一个字符串数组S,找到其中所有的乱序字符串(Anagram)。如果一个字符串是乱序字符串,那么他存在一个字母集合相同,但顺序不同的字符串也在S中。 </p>
</blockquote>
</li>
<li><p>79 动态规划</p>
<blockquote>
<p>给出两个字符串,找到最长公共子串,并返回其长度。</p>
</blockquote>
</li>
<li><p>78 以第一个字符串为基准,暴力查找</p>
<blockquote>
<p>给k个字符串,求出他们的最长公共前缀(LCP) </p>
</blockquote>
</li>
</ul>
<!--noindex-->
<div class="post-button text-center">
<a class="btn" href="/2019/08/05/Lintcode 题解/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</div>
</article>
<article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
<div class="post-block">
<link itemprop="mainEntityOfPage" href="http://yoursite.com/2019/07/11/Core Java 笔记/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="name" content="Faye">
<meta itemprop="description" content="">
<meta itemprop="image" content="/images/photo.jpg">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Faye's Blog">
</span>
<header class="post-header">
<h1 class="post-title" itemprop="name headline">
<a class="post-title-link" href="/2019/07/11/Core Java 笔记/" itemprop="url">
《Core Java》读书笔记
</a>
</h1>
<div class="post-meta">
<span class="post-time">
<span class="post-meta-item-icon">
<i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2019-07-11 17:01:18" itemprop="dateCreated datePublished" datetime="2019-07-11T17:01:18+08:00">2019-07-11</time>
</span>
<span class="post-category" >
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-folder-o"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/读书笔记/" itemprop="url" rel="index"><span itemprop="name">读书笔记</span></a></span>
</span>
<span class="post-comments-count">
<span class="post-meta-divider">|</span>
<span class="post-meta-item-icon">
<i class="fa fa-comment-o"></i>
</span>
<a href="/2019/07/11/Core Java 笔记/#comments" itemprop="discussionUrl">
<span class="post-comments-count disqus-comment-count"
data-disqus-identifier="2019/07/11/Core Java 笔记/" itemprop="commentCount"></span>
</a>
</span>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h2 id="对象与类"><a href="#对象与类" class="headerlink" title="对象与类"></a>对象与类</h2><blockquote>
<p>Java 程序设计语言对对象采用的不是引用调用,实际上,对象引用是按值传递的。</p>
<p>一个方法不能修改一个基本数据类型的参数(即数值型或布尔型)。</p>
<p>一个方法可以改变一个对象参数的状态。</p>
</blockquote>
<ul>
<li>方法得到的参数是对象引用的拷贝,即引用同一个对象</li>
</ul>
<blockquote>
<p>如果多个方法(比如, StringBuilder 构造器方法)有相同的名字、不同的参数,便产生了重载。</p>
</blockquote>
<ul>
<li>举例:indexOf(int) indexOf(int, int) indexOf(String) indexOf(String, int)</li>
</ul>
<h2 id="继承"><a href="#继承" class="headerlink" title="继承"></a>继承</h2><blockquote>
<p>一个对象变量(例如,变量 e ) 可以指示多种实际类型的现象被称为多态(polymorphism)。 在运行时能够自动地选择调用哪个方法的现象称为动态绑定(dynamic binding )。</p>
</blockquote>
<ul>
<li>当 e 引用 Employee 对象时,e.getSalary( ) 调用的是 Employee 类中的 getSalary 方法;当 e 引用 Manager对象时,e.getSalary( ) 调用的是 Manager 类中的 getSalary 方法</li>
<li>一个 Employee 变量既可以引用一个 Employee 类对象,也可以引用一个 Employee 类的任何一个子类的对象</li>
<li>使用多态方法或接口编写的代码比使用对多种类型进行检测的代码更加易于维护和扩展</li>
</ul>
<blockquote>
<p>不允许扩展(extend)的类被称为 final 类。如果在定义类的时候使用了 final 修饰符就表明这个类是 final 类。</p>
<p>类中的特定方法也可以被声明为 final。如果这样做,子类就不能覆盖这个方法。</p>
</blockquote>
<ul>
<li>final 的作用:阻止继承</li>
<li>如果将一个类声明为 final,则其中的方法自动地成为 final,但不包括域</li>
<li>若类中域为 final 域,则该域值不允许被修改</li>
</ul>
<!--noindex-->
<div class="post-button text-center">