-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayload.json
More file actions
2173 lines (2173 loc) · 108 KB
/
Copy pathpayload.json
File metadata and controls
2173 lines (2173 loc) · 108 KB
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
{
"schemaVersion": "1",
"version": "1.0.0",
"graph": {
"slug": "java",
"content": [
{
"locale": "zh-CN",
"name": "Java",
"description": "Java 图谱覆盖 Java 语言、标准库、面向对象、泛型、集合、并发、模块与 JVM 基础。"
},
{
"locale": "en",
"name": "Java",
"description": "The Java graph covers the Java language, standard library, object orientation, generics, collections, concurrency, modules, and JVM fundamentals."
}
]
},
"nodes": [
{
"slug": "java",
"parentSlug": null,
"category": "core",
"sortOrder": 0,
"content": [
{
"locale": "zh-CN",
"title": "Java",
"summary": "Java 是 1995 年推出的静态类型、面向对象语言,代码编译为字节码后由 `JVM` 执行,实现「一次编写,到处运行」。核心设计目标:强类型安全、自动垃圾回收、面向对象。Java 25 是 2025 年 9 月发布的 `LTS` 版本,现代 Java 继续演进模块化、模式匹配、虚拟线程和标准库能力。",
"detail": null
},
{
"locale": "en",
"title": "Java",
"summary": "Java is a statically typed, object-oriented language (1995) whose bytecode runs on the `JVM` for platform independence ('write once, run anywhere'). Core pillars: static typing, garbage collection, and `OOP`. Java 25, released in September 2025, is an `LTS` release, while modern Java continues to evolve modules, pattern matching, virtual threads, and the standard library.",
"detail": null
}
]
},
{
"slug": "language-basics",
"parentSlug": "java",
"category": "core",
"sortOrder": 0,
"content": [
{
"locale": "zh-CN",
"title": "语言基础",
"summary": "语言基础域涵盖 Java 最核心的语法要素:基本数据类型、运算符、控制流语句和数组。这些是编写任何 Java 程序的前提,需要扎实掌握。",
"detail": null
},
{
"locale": "en",
"title": "Language Basics",
"summary": "Language Basics covers Java's foundational syntax: primitive types, operators, control flow, and arrays. Solid mastery of these elements is the prerequisite for any Java program.",
"detail": null
}
]
},
{
"slug": "primitive-types",
"parentSlug": "language-basics",
"category": "core",
"sortOrder": 0,
"content": [
{
"locale": "zh-CN",
"title": "基本类型",
"summary": "Java 有 8 种基本类型:整数(`byte`/`short`/`int`/`long`)、浮点(`float`/`double`)、`char`、`boolean`,存于栈上,不是对象,不能赋 `null`。每种类型有对应包装类(如 `Integer`、`Double`),配合自动装箱/拆箱可用于需要对象的场景。`long` 字面量须加 `L`,`float` 须加 `f`。",
"detail": null
},
{
"locale": "en",
"title": "Primitive Types",
"summary": "Java has 8 primitives: integers (`byte`/`short`/`int`/`long`), floating-point (`float`/`double`), `char`, and `boolean`. They are stored on the stack, are not objects, and cannot hold `null`. Each has a wrapper class (e.g., `Integer`, `Double`) supporting `autoboxing/unboxing`. Append `L` to `long` literals and `f` to `float`.",
"detail": null
}
]
},
{
"slug": "type-casting",
"parentSlug": "language-basics",
"category": "common",
"sortOrder": 1,
"content": [
{
"locale": "zh-CN",
"title": "类型转换",
"summary": "隐式加宽转换:小类型自动转大类型(`int`→`long`→`double`),无数据损失。显式缩窄转换:需强制转换 `(int) 3.14`,可能截断精度。频繁自动装箱/拆箱会产生 GC 压力,注意与 `Integer.parseInt()` 等解析方法的区别。",
"detail": null
},
{
"locale": "en",
"title": "Type Casting",
"summary": "Widening (implicit): smaller types promote to larger automatically with no data loss. Narrowing (explicit): requires a cast `(int) 3.14` and may truncate data. Frequent `autoboxing/unboxing` creates GC pressure; note the difference between casting and parsing (`Integer.parseInt()`).",
"detail": null
}
]
},
{
"slug": "operators",
"parentSlug": "language-basics",
"category": "core",
"sortOrder": 2,
"content": [
{
"locale": "zh-CN",
"title": "运算符",
"summary": "Java 运算符包括:算术(`+` `-` `*` `/` `%`)、关系(`==` `!=` `<` `>`)、逻辑(`&&` `||` `!`,短路求值)、位运算(`&` `|` `^` `<<` `>>`)和三元(`?:`)。`==` 比较基本类型值,比较对象时比较引用地址;对象相等性必须用 `equals()`。整数除法截断小数部分。",
"detail": null
},
{
"locale": "en",
"title": "Operators",
"summary": "Java operators: arithmetic (`+` `-` `*` `/` `%`), relational (`==` `!=` `<` `>`), logical (`&&` `||` `!` with short-circuit), bitwise (`&` `|` `^` `<<` `>>`), and ternary (`?:`). `==` compares primitive values but reference identity for objects—use `equals()` for object equality. Integer division truncates.",
"detail": null
}
]
},
{
"slug": "if-switch",
"parentSlug": "language-basics",
"category": "core",
"sortOrder": 3,
"content": [
{
"locale": "zh-CN",
"title": "条件语句",
"summary": "`if`/`else if`/`else` 是基础条件语句。传统 `switch` 对 `int`/`String`/`enum` 进行等值匹配,需注意 `break` 穿透问题。Switch 表达式(Java 14+)使用 `->` 语法自动阻止穿透并可作为表达式直接返回值,更安全简洁。",
"detail": null
},
{
"locale": "en",
"title": "Conditionals",
"summary": "`if`/`else if`/`else` are the basic conditionals. Traditional `switch` matches `int`/`String`/`enum` with fall-through risk requiring `break`. Switch expressions (Java 14+) use `->` syntax to prevent fall-through and return a value directly—safer and more concise.",
"detail": null
}
]
},
{
"slug": "loops",
"parentSlug": "language-basics",
"category": "core",
"sortOrder": 4,
"content": [
{
"locale": "zh-CN",
"title": "循环",
"summary": "四种循环:`for`(已知次数)、`while`(条件满足时执行)、`do-while`(至少执行一次)和增强 `for-each`(`for (String s : list)`,遍历数组或 `Iterable`)。`for-each` 内部基于迭代器,不暴露索引,不适合按索引修改元素。",
"detail": null
},
{
"locale": "en",
"title": "Loops",
"summary": "Four loop forms: `for` (known count), `while` (condition-based), `do-while` (runs at least once), and enhanced `for-each` (`for (String s : list)` for arrays or `Iterable`). For-each is iterator-backed and does not expose an index.",
"detail": null
}
]
},
{
"slug": "break-continue",
"parentSlug": "language-basics",
"category": "common",
"sortOrder": 5,
"content": [
{
"locale": "zh-CN",
"title": "break 与 continue",
"summary": "`break` 终止最近一层循环或 `switch`;`continue` 跳过当前迭代进入下一次,两者均只影响最近层。带标签的 `break label` 可控制外层循环,但降低可读性,通常应将内层逻辑提取为方法后 `return`。",
"detail": null
},
{
"locale": "en",
"title": "break & continue",
"summary": "`break` exits the innermost loop or `switch`; `continue` skips to the next iteration—both affect only the innermost construct. Labeled `break label` targets outer loops but hurts readability; prefer extracting inner logic into a method and returning.",
"detail": null
}
]
},
{
"slug": "arrays",
"parentSlug": "language-basics",
"category": "core",
"sortOrder": 6,
"content": [
{
"locale": "zh-CN",
"title": "数组",
"summary": "固定长度的同类型元素序列:`int[] arr = new int[5]` 或 `int[] arr = {1,2,3}`。下标从 0 起,越界抛 `ArrayIndexOutOfBoundsException`。多维数组本质是数组的数组,可为锯齿形。`Arrays` 工具类提供 `sort()`、`copyOf()`、`fill()`、`binarySearch()` 等常用操作。",
"detail": null
},
{
"locale": "en",
"title": "Arrays",
"summary": "Fixed-length sequences of the same type: `int[] arr = new int[5]` or `int[] arr = {1,2,3}`. Zero-indexed; out-of-bounds throws `ArrayIndexOutOfBoundsException`. Multi-dimensional arrays are arrays of arrays and can be jagged. `Arrays` provides `sort()`, `copyOf()`, `fill()`, and `binarySearch()`.",
"detail": null
}
]
},
{
"slug": "varargs",
"parentSlug": "language-basics",
"category": "common",
"sortOrder": 7,
"content": [
{
"locale": "zh-CN",
"title": "可变参数(varargs)",
"summary": "`Type... name` 声明可变参数,编译器将其转为数组,允许传 0 到任意个同类型实参。每个方法最多一个 varargs 且必须是最后一个参数,常见于 `printf(String fmt, Object... args)`。重载时 varargs 优先级最低,可能造成歧义。",
"detail": null
},
{
"locale": "en",
"title": "Varargs",
"summary": "Declared with `Type... name`; the compiler converts arguments to an array allowing zero or more values. One varargs per method, must be the last parameter—common in `printf(String fmt, Object... args)`. In overload resolution varargs have the lowest priority and can cause ambiguity.",
"detail": null
}
]
},
{
"slug": "pattern-matching-switch",
"parentSlug": "language-basics",
"category": "common",
"sortOrder": 8,
"content": [
{
"locale": "zh-CN",
"title": "switch 模式匹配",
"summary": "Java 21 正式支持 `switch` 模式匹配:`case String s -> ...` 可按类型匹配并绑定变量,`case null -> ...` 可显式处理空值,`case Shape s when ... -> ...` 可添加守卫条件。配合 `sealed` 类型层次,编译器可以检查分支是否穷举,让类型分派比 `instanceof` 链更简洁、安全。",
"detail": null
},
{
"locale": "en",
"title": "Pattern Matching for switch",
"summary": "Java 21 finalized pattern matching for `switch`: `case String s -> ...` matches by type and binds a variable, `case null -> ...` handles null explicitly, and `case Shape s when ... -> ...` adds a guard. Combined with `sealed` hierarchies, the compiler can check exhaustiveness, making type dispatch safer and more concise than `instanceof` chains.",
"detail": null
}
]
},
{
"slug": "oop",
"parentSlug": "java",
"category": "core",
"sortOrder": 1,
"content": [
{
"locale": "zh-CN",
"title": "面向对象编程",
"summary": "Java 是纯面向对象语言(基本类型除外),一切业务逻辑都组织在类中。`OOP` 四大核心:封装(隐藏实现)、继承(复用与扩展)、多态(一接口多实现)、抽象(提取共性)。",
"detail": null
},
{
"locale": "en",
"title": "Object-Oriented Programming",
"summary": "Java is fully object-oriented (primitives excepted); all logic lives in classes. The four `OOP` pillars: encapsulation (hiding implementation), inheritance (reuse and extension), polymorphism (one interface, many implementations), and abstraction.",
"detail": null
}
]
},
{
"slug": "classes-objects",
"parentSlug": "oop",
"category": "core",
"sortOrder": 0,
"content": [
{
"locale": "zh-CN",
"title": "类与对象",
"summary": "类是对象的模板,通过 `class` 关键字定义,包含字段(状态)和方法(行为)。对象是类的实例,用 `new` 创建。每个 `.java` 文件只能有一个 `public` 类且文件名须与类名一致。",
"detail": null
},
{
"locale": "en",
"title": "Classes & Objects",
"summary": "A class is a blueprint for objects defined with `class`, containing fields (state) and methods (behavior). Objects are instances created with `new`. Each `.java` file may have one `public` class; the filename must match the class name.",
"detail": null
}
]
},
{
"slug": "fields-methods",
"parentSlug": "classes-objects",
"category": "core",
"sortOrder": 0,
"content": [
{
"locale": "zh-CN",
"title": "字段与方法",
"summary": "字段(实例变量)存储对象状态,每个实例独立拥有,有默认值(数值 0,布尔 false,引用 null)。方法通过名称和参数类型(方法签名)区分,支持重载(相同名称、不同参数列表);局部变量必须显式初始化后才能使用。",
"detail": null
},
{
"locale": "en",
"title": "Fields & Methods",
"summary": "Fields (instance variables) store per-object state and have defaults (numeric→0, boolean→false, reference→null). Methods are distinguished by name + parameter types (signature); overloading allows the same name with different parameters. Local variables must be initialized before use.",
"detail": null
}
]
},
{
"slug": "constructors",
"parentSlug": "classes-objects",
"category": "core",
"sortOrder": 1,
"content": [
{
"locale": "zh-CN",
"title": "构造方法",
"summary": "与类同名、无返回类型,在 `new` 时调用以初始化对象。未定义时编译器自动生成无参构造方法;一旦定义了任意构造方法,默认无参构造不再自动生成。`this(...)` 调用同类其他构造方法,`super(...)` 调用父类构造方法,必须是第一条语句。",
"detail": null
},
{
"locale": "en",
"title": "Constructors",
"summary": "Shares the class name and has no return type; called by `new` to initialize the object. If none is defined the compiler generates a no-arg constructor; once any constructor is explicit, the default is gone. `this(...)` delegates to another constructor in the same class; `super(...)` calls the parent's—both must be the first statement.",
"detail": null
}
]
},
{
"slug": "this-keyword",
"parentSlug": "classes-objects",
"category": "common",
"sortOrder": 2,
"content": [
{
"locale": "zh-CN",
"title": "this 关键字",
"summary": "`this` 指向当前实例。主要用途:\n\n1. 区分同名字段与参数 `this.name = name`\n2. 调用同类另一构造方法 `this(arg)`\n3. 将当前对象作为参数或返回值传递。静态方法中不能使用 `this`(无实例上下文)。",
"detail": null
},
{
"locale": "en",
"title": "this Keyword",
"summary": "`this` refers to the current instance. Uses:\n\n1. disambiguate fields from parameters: `this.name = name`\n2. delegate to another constructor: `this(arg)`\n3. pass or return the current object. Cannot be used in static methods—no instance context exists.",
"detail": null
}
]
},
{
"slug": "static-members",
"parentSlug": "classes-objects",
"category": "core",
"sortOrder": 3,
"content": [
{
"locale": "zh-CN",
"title": "静态成员",
"summary": "`static` 字段和方法属于类本身,所有实例共享,通过类名访问;静态方法中不能访问实例字段或调用实例方法(无 `this`)。`static { }` 初始化块在类加载时执行一次,`static final` 字段是编译时常量,惯例全大写命名。",
"detail": null
},
{
"locale": "en",
"title": "Static Members",
"summary": "`static` fields and methods belong to the class; all instances share them, accessed via the class name. Static methods cannot access instance fields or call instance methods (no `this`). `static { }` blocks run once at class loading; `static final` fields are compile-time constants, conventionally ALL_CAPS.",
"detail": null
}
]
},
{
"slug": "access-modifiers",
"parentSlug": "classes-objects",
"category": "core",
"sortOrder": 4,
"content": [
{
"locale": "zh-CN",
"title": "访问修饰符",
"summary": "四种访问级别(从宽到严):`public`(任何地方)、`protected`(同包+子类)、包私有(无修饰符,仅同包)、`private`(仅本类)。字段通常声明为 `private` 配合 `getter/setter` 实现封装;类和接口通常声明为 `public`。",
"detail": null
},
{
"locale": "en",
"title": "Access Modifiers",
"summary": "Four levels (broadest to narrowest): `public` (anywhere), `protected` (same package + subclasses), package-private (no modifier, same package only), `private` (same class only). Fields are typically `private` with `getters/setters` for encapsulation; `classes/interfaces` are usually `public`.",
"detail": null
}
]
},
{
"slug": "extends-keyword",
"parentSlug": "oop",
"category": "core",
"sortOrder": 1,
"content": [
{
"locale": "zh-CN",
"title": "继承(extends)",
"summary": "Java 用 `extends` 实现单继承,子类继承父类所有非私有成员。所有类隐式继承 `Object`,继承建立「is-a」关系。避免深度继承链(>3~4 层),优先用组合代替继承;子类不能缩小父类方法的访问权限。",
"detail": null
},
{
"locale": "en",
"title": "Inheritance (extends)",
"summary": "Java uses `extends` for single inheritance; subclasses inherit all non-private members. Every class implicitly extends `Object`; inheritance models 'is-a'. Avoid deep hierarchies (>3–4 levels) and prefer composition over inheritance. Subclasses cannot reduce access visibility.",
"detail": null
}
]
},
{
"slug": "method-overriding",
"parentSlug": "oop",
"category": "core",
"sortOrder": 2,
"content": [
{
"locale": "zh-CN",
"title": "方法重写",
"summary": "子类重写父类方法时签名必须完全一致,返回类型可为父类返回类型的子类(协变返回)。`@Override` 注解让编译器验证确实是覆盖而非新方法(最佳实践)。`final` 方法不可被重写,`private` 方法不参与继承。",
"detail": null
},
{
"locale": "en",
"title": "Method Overriding",
"summary": "The overriding method must exactly match the parent's signature; the return type may be a subtype (covariant return). `@Override` is best practice—the compiler verifies a true override, catching typos. `final` methods cannot be overridden; `private` methods are not inherited.",
"detail": null
}
]
},
{
"slug": "super-keyword",
"parentSlug": "oop",
"category": "common",
"sortOrder": 3,
"content": [
{
"locale": "zh-CN",
"title": "super 关键字",
"summary": "1. `super.method()` 调用父类被覆盖的方法,用于扩展父类行为\n2. `super(...)` 在子类构造方法中调用父类构造方法,必须是第一条语句。父类无无参构造时,子类必须显式调用 `super(args)` 并传正确参数。",
"detail": null
},
{
"locale": "en",
"title": "super Keyword",
"summary": "1. `super.method()` calls the parent's overridden method, used to extend parent behavior\n2. `super(...)` calls the parent constructor and must be the first statement in a subclass constructor. If the parent has no no-arg constructor, the subclass must explicitly call `super(args)`.",
"detail": null
}
]
},
{
"slug": "final-keyword",
"parentSlug": "oop",
"category": "common",
"sortOrder": 4,
"content": [
{
"locale": "zh-CN",
"title": "final 关键字",
"summary": "三种用途:\n\n1. final 变量只能赋值一次\n2. final 方法不能被子类重写\n3. final 类不能被继承(如 `String`、`Integer`)。注意:final 引用不可改变,但所指对象的内部状态仍可修改。",
"detail": null
},
{
"locale": "en",
"title": "final Keyword",
"summary": "Three uses:\n\n1. final variable: assignable only once\n2. final method: cannot be overridden\n3. final class: cannot be subclassed (e.g., `String`, `Integer`). A final reference cannot be reassigned, but the referenced object may still be mutated internally.",
"detail": null
}
]
},
{
"slug": "interface-definition",
"parentSlug": "oop",
"category": "core",
"sortOrder": 5,
"content": [
{
"locale": "zh-CN",
"title": "接口",
"summary": "`interface` 定义纯抽象的类型契约,方法默认 `public abstract`,字段默认 `public static final`。类用 `implements` 实现多个接口,解决多继承问题;接口建立「can-do」关系,不能被实例化,常作为变量类型实现多态。",
"detail": null
},
{
"locale": "en",
"title": "Interfaces",
"summary": "Interfaces define a pure type contract; methods are implicitly `public abstract`, fields `public static final`. A class uses `implements` to implement multiple interfaces—Java's solution to multiple inheritance. Interfaces model 'can-do' relationships and are commonly used as variable types for polymorphism.",
"detail": null
}
]
},
{
"slug": "default-static-interface-methods",
"parentSlug": "oop",
"category": "common",
"sortOrder": 6,
"content": [
{
"locale": "zh-CN",
"title": "接口默认方法与静态方法",
"summary": "Java 8 引入。默认方法(`default`)有方法体,允许为现有接口添加方法而不破坏实现类(如 `List.sort()`)。静态方法属于接口本身,通过接口名调用,不被实现类继承。多个接口有同名默认方法时,实现类必须显式重写以解决冲突。",
"detail": null
},
{
"locale": "en",
"title": "Default & Static Interface Methods",
"summary": "Java 8 additions. Default methods have a body, enabling new methods on existing interfaces without breaking implementations (e.g., `List.sort()`). Static methods belong to the interface, called via its name, and are not inherited. When two interfaces share a default method name, the implementing class must override to resolve the conflict.",
"detail": null
}
]
},
{
"slug": "abstract-classes",
"parentSlug": "oop",
"category": "core",
"sortOrder": 7,
"content": [
{
"locale": "zh-CN",
"title": "抽象类",
"summary": "`abstract class` 不能直接实例化,可含抽象方法(无方法体,子类必须实现)和具体方法。比接口多:可有构造方法、实例字段和非 public 成员,适合有共同状态的类层次。子类未实现所有抽象方法时,自身也须声明为 `abstract`。",
"detail": null
},
{
"locale": "en",
"title": "Abstract Classes",
"summary": "`abstract class` cannot be instantiated; it may contain abstract methods (no body; subclasses must implement) and concrete ones. Unlike interfaces, abstract classes can have constructors, instance fields, and non-public members—best for hierarchies sharing common state. A subclass that doesn't implement all abstract methods must also be abstract.",
"detail": null
}
]
},
{
"slug": "polymorphism",
"parentSlug": "oop",
"category": "core",
"sortOrder": 8,
"content": [
{
"locale": "zh-CN",
"title": "多态",
"summary": "父类引用指向子类对象,调用方法时执行子类实现(动态分派):`Animal a = new Dog(); a.speak()` 实际调用 `Dog.speak()`。编译时多态(重载)由参数类型决定;运行时多态(重写+动态绑定)由实际对象类型决定,实现「开闭原则」。",
"detail": null
},
{
"locale": "en",
"title": "Polymorphism",
"summary": "A parent-type reference pointing to a subclass invokes the subclass's method at runtime (dynamic dispatch): `Animal a = new Dog(); a.speak()` calls `Dog.speak()`. Compile-time polymorphism (overloading) is resolved by parameter types; runtime polymorphism (overriding + dynamic binding) by the actual object type, enabling the `open/closed` principle.",
"detail": null
}
]
},
{
"slug": "encapsulation",
"parentSlug": "oop",
"category": "core",
"sortOrder": 9,
"content": [
{
"locale": "zh-CN",
"title": "封装",
"summary": "将字段声明为 `private`,通过 public `getter/setter` 控制访问,隐藏实现细节并保护数据完整性。setter 中可加入校验逻辑;良好封装使内部可自由重构而不影响调用方。过度暴露 `getter/setter`(贫血模型)是反模式。",
"detail": null
},
{
"locale": "en",
"title": "Encapsulation",
"summary": "Declare fields `private` and expose access through public `getters/setters`, hiding implementation and protecting data integrity. Setters can enforce validation; good encapsulation allows internal refactoring without breaking callers. Excessive `getters/setters` (anemic model) is an anti-pattern.",
"detail": null
}
]
},
{
"slug": "enums",
"parentSlug": "oop",
"category": "common",
"sortOrder": 10,
"content": [
{
"locale": "zh-CN",
"title": "枚举(enum)",
"summary": "`enum` 定义一组类型安全的命名常量,可用于 `switch`,可以有字段、构造方法和方法。`values()` 返回所有枚举值,`name()` 返回常量名,`ordinal()` 返回序号(不建议依赖)。枚举适合替代魔法 `int`/`String` 常量,类型更安全。",
"detail": null
},
{
"locale": "en",
"title": "Enums",
"summary": "`enum` defines a type-safe set of named constants usable in `switch`; enums can have fields, constructors, and methods. `values()` returns all constants; `name()` returns the constant's name; `ordinal()` returns its index (avoid depending on it). Enums are the type-safe replacement for magic `int`/`String` constants.",
"detail": null
}
]
},
{
"slug": "records",
"parentSlug": "oop",
"category": "common",
"sortOrder": 11,
"content": [
{
"locale": "zh-CN",
"title": "记录类(record)",
"summary": "`record`(Java 16+)是不可变数据载体的简洁语法:`record Point(int x, int y) {}` 自动生成全参构造方法、`equals()`、`hashCode()`、`toString()`。字段默认 `private final`,不能继承其他类,可实现接口。紧凑构造方法适合加入参数校验逻辑。",
"detail": null
},
{
"locale": "en",
"title": "Records",
"summary": "`record` (Java 16+) is concise syntax for immutable data carriers: `record Point(int x, int y) {}` auto-generates a canonical constructor, `equals()`, `hashCode()`, and `toString()`. Fields are implicitly `private final`; records cannot extend classes but may implement interfaces. The compact constructor is ideal for validation.",
"detail": null
}
]
},
{
"slug": "sealed-classes",
"parentSlug": "oop",
"category": "rare",
"sortOrder": 12,
"content": [
{
"locale": "zh-CN",
"title": "密封类(sealed)",
"summary": "`sealed class`(Java 17+)通过 `permits` 子句限制可继承的子类,被允许的子类须声明为 `final`、`sealed` 或 `non-sealed`。配合 switch 模式匹配,编译器可验证 switch 的穷举性,适合建模固定的类型层次(如 `AST` 节点、`API` 响应变体)。",
"detail": null
},
{
"locale": "en",
"title": "Sealed Classes",
"summary": "`sealed class` (Java 17+) restricts which classes may extend it via a `permits` clause; permitted subclasses must be `final`, `sealed`, or `non-sealed`. Combined with switch pattern matching the compiler can verify exhaustiveness, making it ideal for fixed type hierarchies like `AST` nodes or `API` response variants.",
"detail": null
}
]
},
{
"slug": "nested-classes",
"parentSlug": "oop",
"category": "common",
"sortOrder": 13,
"content": [
{
"locale": "zh-CN",
"title": "嵌套类",
"summary": "四种嵌套类:\n\n1. 静态嵌套类(`static class`,无法访问外部实例成员,最常用)\n2. 内部类(持有外部实例引用,易内存泄漏)\n3. 局部类(方法内部定义)\n4. 匿名类(`new Runnable() { ... }`,现代 Java 中已被 lambda 大量替代)。",
"detail": null
},
{
"locale": "en",
"title": "Nested Classes",
"summary": "Four kinds:\n\n1. static nested class (`static class`, no outer instance access—most common)\n2. inner class (holds outer instance reference, risks memory leaks)\n3. local class (inside a method)\n4. anonymous class (`new Runnable() { ... }`, largely replaced by lambdas in modern Java).",
"detail": null
}
]
},
{
"slug": "instanceof-pattern",
"parentSlug": "oop",
"category": "common",
"sortOrder": 14,
"content": [
{
"locale": "zh-CN",
"title": "instanceof 模式匹配",
"summary": "传统 `instanceof`:先判断类型再强制转换。模式匹配(Java 16+):`if (obj instanceof String s)` 判断为 true 后自动绑定变量 `s`,无需显式转型。Java 21 的 switch 模式匹配进一步支持:`switch(shape) { case Circle c -> ...; }`,配合密封类可实现穷举检查。",
"detail": null
},
{
"locale": "en",
"title": "instanceof Pattern Matching",
"summary": "Traditional `instanceof` requires a separate cast. Pattern matching (Java 16+): `if (obj instanceof String s)` automatically binds `s` in the true branch—no explicit cast needed. Java 21 extends this to switch: `switch(shape) { case Circle c -> ...; }`, enabling exhaustiveness checks with sealed classes.",
"detail": null
}
]
},
{
"slug": "generics",
"parentSlug": "java",
"category": "core",
"sortOrder": 2,
"content": [
{
"locale": "zh-CN",
"title": "泛型",
"summary": "泛型让类、接口和方法在保持类型安全的前提下处理多种类型,核心价值:编译时类型检查、消除强制转型、提高代码复用。`List<String>` 只能存 `String`,编译器静态检查,运行时类型参数被擦除(类型擦除)。",
"detail": null
},
{
"locale": "en",
"title": "Generics",
"summary": "Generics let classes, interfaces, and methods work with multiple types while maintaining type safety. Core value: compile-time type checking, eliminating casts, and increasing reuse. `List<String>` accepts only `String`; enforced statically. Type parameters are erased at runtime.",
"detail": null
}
]
},
{
"slug": "generic-classes-methods",
"parentSlug": "generics",
"category": "core",
"sortOrder": 0,
"content": [
{
"locale": "zh-CN",
"title": "泛型类与泛型方法",
"summary": "泛型类:`class Box<T> { T value; }` 实例化时指定具体类型 `Box<String>`。泛型方法:`<T> T first(List<T> list)`,调用时由实参推断类型。泛型是现代 Java 容器 `API`(`List`/`Map`/`Optional`)的基础。",
"detail": null
},
{
"locale": "en",
"title": "Generic Classes & Methods",
"summary": "Generic class: `class Box<T> { T value; }` instantiated as `Box<String>`. Generic method: `<T> T first(List<T> list)` with the type inferred from arguments. Generics are the foundation of type-safe container `APIs` (`List`, `Map`, `Optional`).",
"detail": null
}
]
},
{
"slug": "type-bounds",
"parentSlug": "generics",
"category": "common",
"sortOrder": 1,
"content": [
{
"locale": "zh-CN",
"title": "类型边界",
"summary": "`<T extends Number>` 限制类型参数必须是 `Number` 的子类,方法体内可安全调用 `Number` 方法。`<T extends Comparable<T>>` 常用于排序算法。多边界:`<T extends A & B>`(类必须排第一)。无边界时默认等价于 `<T extends Object>`。",
"detail": null
},
{
"locale": "en",
"title": "Type Bounds",
"summary": "`<T extends Number>` constrains T to subclasses of `Number`, enabling safe calls to `Number` methods in the body. `<T extends Comparable<T>>` is common in sorting. Multiple bounds: `<T extends A & B>` (class must come first). Without a bound `<T>` implicitly means `<T extends Object>`.",
"detail": null
}
]
},
{
"slug": "wildcards",
"parentSlug": "generics",
"category": "common",
"sortOrder": 2,
"content": [
{
"locale": "zh-CN",
"title": "通配符",
"summary": "`?` 是未知类型通配符。上界(`List<? extends Number>`):可读取 Number 类型,不能写入(生产者)。下界(`List<? super Integer>`):可写入 Integer,读取为 Object(消费者)。`PECS` 原则:Producer Extends,Consumer Super。",
"detail": null
},
{
"locale": "en",
"title": "Wildcards",
"summary": "`?` is an unknown type wildcard. Upper bound (`List<? extends Number>`): read as Number, cannot write (producer). Lower bound (`List<? super Integer>`): write Integer, read as Object (consumer). `PECS` principle: Producer Extends, Consumer Super.",
"detail": null
}
]
},
{
"slug": "type-erasure",
"parentSlug": "generics",
"category": "rare",
"sortOrder": 3,
"content": [
{
"locale": "zh-CN",
"title": "类型擦除",
"summary": "Java 泛型通过类型擦除实现:编译后类型参数被替换为边界类型(无边界则为 `Object`),运行时 `List<String>` 和 `List<Integer>` 是同一个类。因此不能用 `instanceof List<String>`,不能创建 `new T()` 或 `T[]`,类型擦除保证了与 Java 5 前代码的二进制兼容性。",
"detail": null
},
{
"locale": "en",
"title": "Type Erasure",
"summary": "Generics are implemented via type erasure: type parameters are replaced by their bound (or `Object`) after compilation. At runtime `List<String>` and `List<Integer>` are the same class. Consequences: no `instanceof List<String>`, no `new T()`, no `T[]`. Erasure preserves binary compatibility with pre-Java-5 code.",
"detail": null
}
]
},
{
"slug": "collections",
"parentSlug": "java",
"category": "core",
"sortOrder": 3,
"content": [
{
"locale": "zh-CN",
"title": "Collections 框架",
"summary": "Java Collections Framework 提供统一的泛型数据结构:`List`、`Set`、`Map`、`Queue`/`Deque`,并在有序结构上提供 Sequenced Collections 接口。选择集合时要同时考虑顺序、重复元素、查找复杂度、并发需求和空值策略。算法和包装工具集中在 `Collections`,数组相关工具在 `Arrays`。",
"detail": null
},
{
"locale": "en",
"title": "Collections Framework",
"summary": "The Java Collections Framework provides unified generic data structures: `List`, `Set`, `Map`, and `Queue`/`Deque`, with Sequenced Collections interfaces for ordered structures. Choose a collection by considering order, duplicates, lookup complexity, concurrency needs, and null handling. Algorithms and wrappers live in `Collections`, while array utilities live in `Arrays`.",
"detail": null
}
]
},
{
"slug": "arraylist",
"parentSlug": "collections",
"category": "core",
"sortOrder": 0,
"content": [
{
"locale": "zh-CN",
"title": "ArrayList",
"summary": "基于动态数组的 `List`:随机访问 `O(1)`,末尾增删 `O(1) 均摊(扩容时 O(n)`),中间插删 `O(n)`。默认容量 10,每次扩容约 1.5 倍;预知大小时构造时传入容量可避免多次扩容。线程不安全,并发场景用 `CopyOnWriteArrayList`。",
"detail": null
},
{
"locale": "en",
"title": "ArrayList",
"summary": "Dynamic-array-backed `List`: `O(1) random access, O(1) amortized appends (O(n) on resize), O(n)` mid-list insert/delete. Default capacity 10, grows ~1.5× on resize—pass expected size to the constructor to avoid repeated resizing. Not thread-safe; use `CopyOnWriteArrayList` for concurrent access.",
"detail": null
}
]
},
{
"slug": "linkedlist",
"parentSlug": "collections",
"category": "common",
"sortOrder": 1,
"content": [
{
"locale": "zh-CN",
"title": "LinkedList",
"summary": "双向链表,同时实现 `List` 和 `Deque`。首尾增删 `O(1)`,随机访问 `O(n)`,内存开销比 `ArrayList` 大(每节点含前后指针)。适合用作队列或栈;纯 List 场景下性能通常不及 `ArrayList`。",
"detail": null
},
{
"locale": "en",
"title": "LinkedList",
"summary": "Doubly-linked list implementing both `List` and `Deque`. `O(1)` `head/tail` operations, `O(n)` random access; higher memory overhead than `ArrayList` (`prev/next` pointers per node). Best used as a queue or stack; as a plain `List` it is usually slower than `ArrayList`.",
"detail": null
}
]
},
{
"slug": "hashset",
"parentSlug": "collections",
"category": "core",
"sortOrder": 2,
"content": [
{
"locale": "zh-CN",
"title": "HashSet",
"summary": "基于 `HashMap` 实现的 `Set`,元素唯一无序。`add()`/`contains()`/`remove()` 平均 `O(1)`。要求元素正确实现 `equals()` 和 `hashCode()`,违反合约会导致元素丢失或查找失败。默认容量 16,负载因子 0.75。",
"detail": null
},
{
"locale": "en",
"title": "HashSet",
"summary": "Backed by `HashMap`, implements `Set` with unique unordered elements. `O(1)` average `add()`/`contains()`/`remove()`. Requires correct `equals()` and `hashCode()`—violations cause lost elements or failed lookups. Default capacity 16, load factor 0.75.",
"detail": null
}
]
},
{
"slug": "treeset",
"parentSlug": "collections",
"category": "common",
"sortOrder": 3,
"content": [
{
"locale": "zh-CN",
"title": "TreeSet",
"summary": "基于红黑树的有序 `Set`,元素按自然顺序(`Comparable`)或指定 `Comparator` 排序,操作均为 `O(log n)`。提供 `first()`/`last()`/`headSet()`/`tailSet()`/`subSet()` 等范围操作,适合有序遍历或范围查询场景。元素必须可比较,否则抛 `ClassCastException`。",
"detail": null
},
{
"locale": "en",
"title": "TreeSet",
"summary": "Red-black tree backed sorted `Set`: elements ordered by natural ordering (`Comparable`) or a `Comparator`. `O(log n)` operations. Offers range navigation: `first()`, `last()`, `headSet()`, `tailSet()`, `subSet()`. Elements must be comparable; otherwise `ClassCastException` is thrown.",
"detail": null
}
]
},
{
"slug": "hashmap",
"parentSlug": "collections",
"category": "core",
"sortOrder": 4,
"content": [
{
"locale": "zh-CN",
"title": "HashMap",
"summary": "最常用的 `Map` 实现,基于哈希表。`put()`/`get()`/`containsKey()` 平均 `O(1)`。键必须正确实现 `equals()` 和 `hashCode()`。Java 8+ 链表超长(>8 元素)时转为红黑树。允许一个 `null` 键。线程不安全,并发场景用 `ConcurrentHashMap`。",
"detail": null
},
{
"locale": "en",
"title": "HashMap",
"summary": "The most common `Map`, hash-table-based. `O(1)` average `put()`/`get()`/`containsKey()`. Keys must properly implement `equals()` and `hashCode()`. Java 8+ converts long chains (>8) to red-black trees. Allows one `null` key. Not thread-safe; use `ConcurrentHashMap` for concurrency.",
"detail": null
}
]
},
{
"slug": "treemap",
"parentSlug": "collections",
"category": "common",
"sortOrder": 5,
"content": [
{
"locale": "zh-CN",
"title": "TreeMap",
"summary": "基于红黑树的有序 `Map`,键按自然顺序或 `Comparator` 排序,操作 `O(log n)`。提供 `firstKey()`/`lastKey()`/`headMap()`/`tailMap()`/`subMap()` 等范围查询操作,不允许 `null` 键。",
"detail": null
},
{
"locale": "en",
"title": "TreeMap",
"summary": "Red-black tree backed `Map` with keys sorted by natural ordering or a `Comparator`. `O(log n)` operations. Range navigation: `firstKey()`, `lastKey()`, `headMap()`, `tailMap()`, `subMap()`. Does not allow `null` keys.",
"detail": null
}
]
},
{
"slug": "linkedhashmap",
"parentSlug": "collections",
"category": "rare",
"sortOrder": 6,
"content": [
{
"locale": "zh-CN",
"title": "LinkedHashMap",
"summary": "继承 `HashMap`,额外维护双向链表保证插入顺序(默认)或访问顺序(`accessOrder=true`)的遍历。访问顺序模式可轻松实现 `LRU` 缓存:重写 `removeEldestEntry()` 即可。性能接近 `HashMap`,但有额外的链表内存开销。",
"detail": null
},
{
"locale": "en",
"title": "LinkedHashMap",
"summary": "Extends `HashMap` with a doubly-linked list preserving insertion order (default) or access order (`accessOrder=true`). Access-order mode enables easy `LRU` caches by overriding `removeEldestEntry()`. Performance close to `HashMap` with additional linked-list memory overhead.",
"detail": null
}
]
},
{
"slug": "queue-deque",
"parentSlug": "collections",
"category": "common",
"sortOrder": 7,
"content": [
{
"locale": "zh-CN",
"title": "Queue 与 Deque",
"summary": "`Queue`:`FIFO`,`offer()` 入队,`poll()` 出队(空返回 null),`peek()` 查看队首。`Deque`:双端队列,可用作栈(`push()`/`pop()`)。推荐实现:`ArrayDeque`(比 `Stack`/`LinkedList` 快);`PriorityQueue`(按优先级出队,基于堆)。",
"detail": null
},
{
"locale": "en",
"title": "Queue & Deque",
"summary": "`Queue`: `FIFO`; `offer()` enqueues, `poll()` dequeues (null if empty), `peek()` inspects head. `Deque`: double-ended; works as a stack (`push()`/`pop()`). Recommended: `ArrayDeque` (faster than `Stack`/`LinkedList`); `PriorityQueue` (heap-backed, highest-priority first).",
"detail": null
}
]
},
{
"slug": "comparable-comparator",
"parentSlug": "collections",
"category": "common",
"sortOrder": 8,
"content": [
{
"locale": "zh-CN",
"title": "Comparable 与 Comparator",
"summary": "`Comparable<T>` 定义对象自然顺序(实现 `compareTo()`),供 `Collections.sort()` 和 `TreeSet`/`TreeMap` 使用。`Comparator<T>` 是外部比较器(`compare()` 方法),可通过 `Comparator.comparing(fn).thenComparing(...)` 链式组合,更灵活,不修改类本身。",
"detail": null
},
{
"locale": "en",
"title": "Comparable & Comparator",
"summary": "`Comparable<T>` defines natural ordering via `compareTo()`, used by `Collections.sort()` and `TreeSet`/`TreeMap`. `Comparator<T>` is an external comparator (`compare()` method), chainable with `Comparator.comparing(fn).thenComparing(...)`. More flexible—does not require modifying the class.",
"detail": null
}
]
},
{
"slug": "iterator-iterable",
"parentSlug": "collections",
"category": "rare",
"sortOrder": 9,
"content": [
{
"locale": "zh-CN",
"title": "Iterator 与 Iterable",
"summary": "`Iterable<T>` 实现 `iterator()` 方法即可被 `for-each` 遍历。`Iterator<T>` 提供 `hasNext()`、`next()` 和 `remove()`,其中 `remove()` 是遍历中安全删除元素的唯一方式——直接调用集合的 `remove()` 会抛 `ConcurrentModificationException`。自定义集合实现 `Iterable` 即可接入语言级 `for-each`。",
"detail": null
},
{
"locale": "en",
"title": "Iterator & Iterable",
"summary": "`Iterable<T>` exposes `iterator()` to enable `for-each` loops. `Iterator<T>` provides `hasNext()`, `next()`, and `remove()`; `iterator.remove()` is the only safe way to delete during iteration—calling the collection's `remove()` directly throws `ConcurrentModificationException`. Implement `Iterable` on custom collections to integrate with the language-level `for-each`.",
"detail": null
}
]
},
{
"slug": "collections-utility",
"parentSlug": "collections",
"category": "common",
"sortOrder": 10,
"content": [
{
"locale": "zh-CN",
"title": "Collections 工具类",
"summary": "`java.util.Collections` 提供静态算法:`sort()`、`shuffle()`、`reverse()`、`min()`/`max()`、`binarySearch()`、`unmodifiableList()`(不可修改视图)、`synchronizedList()`(线程安全包装)。`Collections.emptyList()`/`singletonList()` 返回轻量不可变列表。",
"detail": null
},
{
"locale": "en",
"title": "Collections Utility Class",
"summary": "`java.util.Collections` provides static algorithms: `sort()`, `shuffle()`, `reverse()`, `min()`/`max()`, `binarySearch()`, `unmodifiableList()` (read-only view), `synchronizedList()` (thread-safe wrapper). `emptyList()` and `singletonList()` return lightweight immutable lists.",
"detail": null
}
]
},
{