-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjava.mm
4011 lines (3994 loc) · 245 KB
/
java.mm
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
<map version="1.0.1">
<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->
<node CREATED="1344928688194" ID="ID_469395458" MODIFIED="1457405469913" TEXT="java">
<node CREATED="1312185565053" ID="ID_35294482" MODIFIED="1510561950196" POSITION="right" TEXT="java language basic">
<node CREATED="1345106669823" ID="ID_1251747125" MODIFIED="1388469228554" TEXT="type">
<node CREATED="1312185600845" ID="ID_16075161" MODIFIED="1368930560012" TEXT="primitive types">
<node CREATED="1312185623114" ID="ID_1450697019" MODIFIED="1312185642665" TEXT="byte"/>
<node CREATED="1312185627981" ID="ID_1321392451" MODIFIED="1312185644666" TEXT="short"/>
<node CREATED="1312185617441" ID="ID_1386705387" MODIFIED="1312185622864" TEXT="int"/>
<node CREATED="1312185629499" ID="ID_303601940" MODIFIED="1312185646349" TEXT="long"/>
<node CREATED="1312185651279" ID="ID_1544271899" MODIFIED="1312185655736" TEXT="float"/>
<node CREATED="1312185647272" ID="ID_1160215808" MODIFIED="1312185649235" TEXT="double"/>
<node CREATED="1312185625968" ID="ID_680977593" MODIFIED="1312185627741" TEXT="char">
<node CREATED="1345106061421" ID="ID_996506170" MODIFIED="1345106104077" TEXT="utf-16 '\u0000'~'\uffff'"/>
</node>
<node CREATED="1312185630633" ID="ID_1336939222" MODIFIED="1312185664111" TEXT="boolean"/>
<node CREATED="1345106215423" FOLDED="true" ID="ID_435475238" MODIFIED="1368930564851" TEXT="literal">
<node CREATED="1345106232076" ID="ID_1061175292" MODIFIED="1345106253970" TEXT="0x (hex)"/>
<node CREATED="1345106238611" ID="ID_838668602" MODIFIED="1345106256976" TEXT="0b (bin)"/>
<node CREATED="1345106240128" ID="ID_197769631" MODIFIED="1345106261198" TEXT="0 (oct)"/>
<node CREATED="1345106463105" ID="ID_147180219" MODIFIED="1345106473669" TEXT="_(JDK7)">
<node CREATED="1345106456104" ID="ID_1965036598" MODIFIED="1345106458973" TEXT="any number of underscore characters (_) can appear anywhere between digits in a numerical literal."/>
</node>
<node CREATED="1345106477615" ID="ID_1750360624" MODIFIED="1345106486825" TEXT="L/l"/>
<node CREATED="1345106479592" ID="ID_453270008" MODIFIED="1345106490795" TEXT="F/f"/>
<node CREATED="1345106482707" ID="ID_1035410511" MODIFIED="1345106493748" TEXT="D/d"/>
</node>
</node>
<node CREATED="1345106677720" FOLDED="true" ID="ID_504169155" MODIFIED="1368930568743" TEXT="array">
<node CREATED="1345106722315" ID="ID_989614311" MODIFIED="1345106727582" TEXT="defintion">
<node COLOR="#338800" CREATED="1345106682630" ID="ID_1509434023" MODIFIED="1345106770291" TEXT="Type[] array=new Type[N] "/>
<node COLOR="#338800" CREATED="1345106852132" ID="ID_641156791" MODIFIED="1345106869261" TEXT="Type[] array={,,...}"/>
<node COLOR="#ff0000" CREATED="1345106734286" ID="ID_196438211" MODIFIED="1345106759773" TEXT="Type array[]=new Type[N] (deprecated)">
<icon BUILTIN="stop-sign"/>
</node>
</node>
<node CREATED="1345106776842" ID="ID_1379703684" MODIFIED="1345106896716" TEXT="length">
<node CREATED="1345106898270" ID="ID_48917291" MODIFIED="1345106902969" TEXT="array.length"/>
</node>
<node CREATED="1345106905286" ID="ID_1208924419" MODIFIED="1345106908072" TEXT="copy">
<node CREATED="1345106935812" ID="ID_1166346046" MODIFIED="1345106935812">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>public static void arraycopy(Object src, int srcPos,
Object dest, int destPos, int length)</pre>
</body>
</html></richcontent>
</node>
</node>
</node>
<node CREATED="1345107140268" FOLDED="true" ID="ID_1245458467" MODIFIED="1368930571363" TEXT="operator">
<node CREATED="1345107148849" ID="ID_1442090007" MODIFIED="1345107160377" TEXT=">>> ">
<node CREATED="1345107190307" ID="ID_396800619" MODIFIED="1345107190307">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
unsigned right shift
</body>
</html></richcontent>
</node>
</node>
<node CREATED="1345107191690" ID="ID_1652281941" MODIFIED="1357390386857" TEXT="instanceof()">
<node CREATED="1345107249589" ID="ID_1629200540" MODIFIED="1357726912856" TEXT="Type Comparison (RTTI)"/>
</node>
</node>
</node>
<node CREATED="1345183697036" FOLDED="true" ID="ID_274496348" MODIFIED="1388469237080" TEXT="OOP">
<node CREATED="1345183817786" ID="ID_606728563" MODIFIED="1357389716055" TEXT="support overload ">
<node CREATED="1345183900497" ID="ID_515295403" MODIFIED="1357389745516" TEXT="method signature">
<node CREATED="1345183918121" ID="ID_16272707" MODIFIED="1357389753284" TEXT="method name and parameter list"/>
</node>
<node CREATED="1345184030201" ID="ID_187536055" MODIFIED="1345184061865" TEXT="same method name ,different parameter lists"/>
</node>
<node CREATED="1345186413655" FOLDED="true" ID="ID_1036717929" MODIFIED="1368930577787" TEXT="access level modifiers">
<node CREATED="1345186416826" ID="ID_354924338" MODIFIED="1345186416826">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<table>
<caption id="accesscontrol-levels" style="font-weight: bold">
Access Levels
</caption>
<tr>
<th id="h1">
Modifier
</th>
<th id="h2">
Class
</th>
<th id="h3">
Package
</th>
<th id="h4">
Subclass
</th>
<th id="h5">
World
</th>
</tr>
<tr>
<td headers="h1">
<code>public</code>
</td>
<td headers="h2">
Y
</td>
<td headers="h3">
Y
</td>
<td headers="h4">
Y
</td>
<td headers="h5">
Y
</td>
</tr>
<tr>
<td headers="h1">
<code>protected</code>
</td>
<td headers="h2">
Y
</td>
<td headers="h3">
Y
</td>
<td headers="h4">
Y
</td>
<td headers="h5">
N
</td>
</tr>
<tr>
<td headers="h1" style="font-style: italic">
no modifier
</td>
<td headers="h2">
Y
</td>
<td headers="h3">
Y
</td>
<td headers="h4">
N
</td>
<td headers="h5">
N
</td>
</tr>
<tr>
<td headers="h1">
<code>private</code>
</td>
<td headers="h2">
Y
</td>
<td headers="h3">
N
</td>
<td headers="h4">
N
</td>
<td headers="h5">
N
</td>
</tr>
</table>
</body>
</html></richcontent>
</node>
</node>
<node CREATED="1345186668306" FOLDED="true" ID="ID_409333134" MODIFIED="1368930581372" TEXT="Class members vs Instance members">
<node CREATED="1345186698418" ID="ID_963217742" MODIFIED="1345186700571" TEXT="Class">
<node CREATED="1345186721533" ID="ID_1405341400" MODIFIED="1345186747184" TEXT="static variable"/>
<node CREATED="1345186747679" ID="ID_1298211779" MODIFIED="1345186752901" TEXT="static method"/>
</node>
<node CREATED="1345186700993" ID="ID_549433678" MODIFIED="1345186706549" TEXT="Instance">
<node CREATED="1345186754952" ID="ID_970452344" MODIFIED="1345186764483" TEXT="non-static variable"/>
<node CREATED="1345186764738" ID="ID_939184188" MODIFIED="1345186771239" TEXT="non-static method"/>
</node>
<node CREATED="1345187171358" ID="ID_1356338790" MODIFIED="1357389833219" TEXT="accessible">
<node CREATED="1345187201861" ID="ID_1218588683" MODIFIED="1345187351634" TEXT="Instance methods can access instance variables and instance methods directly.">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1345187217201" ID="ID_162873331" MODIFIED="1345187353042" TEXT=" Instance methods can access class variables and class methods directly.">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1345187223675" ID="ID_191985217" MODIFIED="1345187353867" TEXT="Class methods can access class variables and class methods directly.">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1345187257695" ID="ID_1508513559" MODIFIED="1345187378866">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
Class methods <b>cannot</b> access instance variables or instance methods directly
</p>
</body>
</html></richcontent>
<icon BUILTIN="button_cancel"/>
</node>
</node>
<node CREATED="1345187276453" FOLDED="true" ID="ID_55284732" MODIFIED="1366551694432" TEXT="qualifying">
<node CREATED="1345187337756" ID="ID_1771715008" MODIFIED="1345187422701" TEXT="static members can be qualified by Class Name">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1345187424347" ID="ID_415909575" MODIFIED="1345189483386" TEXT="static member can be qualified by instance reference(discouraged)">
<icon BUILTIN="messagebox_warning"/>
</node>
<node CREATED="1345189485466" ID="ID_56293288" MODIFIED="1345189525503" TEXT="instance members can be qualified by instance reference"/>
<node CREATED="1345189526986" ID="ID_1259842680" MODIFIED="1366551686660" TEXT="instance members cannot be qualified by instance reference"/>
</node>
<node CREATED="1345192600271" FOLDED="true" ID="ID_1351478942" MODIFIED="1366551700159" TEXT="Initializing Fields">
<node CREATED="1345193024964" ID="ID_1772883338" MODIFIED="1345193043273" TEXT="Class fields">
<node CREATED="1345192624795" ID="ID_988840686" MODIFIED="1345193294947" TEXT="static initialization blocks">
<node CREATED="1345192713850" ID="ID_1335061245" MODIFIED="1345192713850">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>static {
// whatever code is needed for initialization goes here
}</pre>
</body>
</html></richcontent>
</node>
</node>
<node CREATED="1345193064917" ID="ID_575130761" MODIFIED="1345193184196" TEXT="initializing while defining"/>
</node>
<node CREATED="1345193050458" ID="ID_96484748" MODIFIED="1345193057415" TEXT="Instance fields">
<node CREATED="1345192998323" ID="ID_730645265" MODIFIED="1345193202787" TEXT="initializing while defining"/>
<node CREATED="1345193203299" ID="ID_1530806349" MODIFIED="1345193210823" TEXT="constructor"/>
<node CREATED="1345193211333" ID="ID_546962865" MODIFIED="1345193254730" TEXT="final instance method"/>
<node CREATED="1345193255206" ID="ID_378007647" MODIFIED="1345193326333" TEXT="initialization blocks">
<node CREATED="1345193321058" ID="ID_1681745599" MODIFIED="1345193321058">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>{
// whatever code is needed for initialization goes here
}</pre>
</body>
</html></richcontent>
</node>
</node>
</node>
<node CREATED="1345193675823" ID="ID_1829554050" MODIFIED="1345193680349" TEXT="final fields">
<node CREATED="1345193416344" ID="ID_50004394" MODIFIED="1345193468502" TEXT="final fields(both Class fields and Instance fields) must be initialized">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1345193470051" ID="ID_1526342921" MODIFIED="1345193669436" TEXT="un-intialized non-final fields has default initial value 0">
<icon BUILTIN="button_ok"/>
</node>
</node>
</node>
</node>
<node CREATED="1345295566073" ID="ID_1525350285" MODIFIED="1368930582318" TEXT="type">
<node CREATED="1345295571785" ID="ID_550658258" MODIFIED="1345295573836" TEXT="class"/>
<node CREATED="1345295574117" FOLDED="true" ID="ID_345582349" MODIFIED="1368932710908" TEXT="enum">
<node CREATED="1368931377678" FOLDED="true" ID="ID_1849039765" MODIFIED="1368932368079" TEXT="demos">
<node CREATED="1368931370109" ID="ID_1681574904" MODIFIED="1368931370109">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>public enum Planet {
MERCURY (3.303e+23, 2.4397e6),
VENUS (4.869e+24, 6.0518e6),
EARTH (5.976e+24, 6.37814e6),
MARS (6.421e+23, 3.3972e6),
JUPITER (1.9e+27, 7.1492e7),
SATURN (5.688e+26, 6.0268e7),
URANUS (8.686e+25, 2.5559e7),
NEPTUNE (1.024e+26, 2.4746e7);
private final double mass; // in kilograms
private final double radius; // in meters
Planet(double mass, double radius) {
this.mass = mass;
this.radius = radius;
}
private double mass() { return mass; }
private double radius() { return radius; }
// universal gravitational constant (m3 kg-1 s-2)
public static final double G = 6.67300E-11;
double surfaceGravity() {
return G * mass / (radius * radius);
}
double surfaceWeight(double otherMass) {
return otherMass * surfaceGravity();
}
public static void main(String[] args) {
if (args.length != 1) {
System.err.println("Usage: java Planet <earth_weight>");
System.exit(-1);
}
double earthWeight = Double.parseDouble(args[0]);
double mass = earthWeight/EARTH.surfaceGravity();
for (Planet p : Planet.values())
System.out.printf("Your weight on %s is %f%n",
p, p.surfaceWeight(mass));
}
}</pre>
</body>
</html></richcontent>
</node>
</node>
<node CREATED="1368932032735" FOLDED="true" ID="ID_451042358" MODIFIED="1368932401027" TEXT="special class extends Enum">
<node CREATED="1368932146718" ID="ID_1475274356" MODIFIED="1368932190761" TEXT="String name()"/>
<node CREATED="1368932191879" ID="ID_989515401" MODIFIED="1368932205122" TEXT="int ordinal()"/>
<node CREATED="1368932228974" FOLDED="true" ID="ID_1966830115" MODIFIED="1368932360891" TEXT="String toString()">
<node CREATED="1368932234142" ID="ID_303542168" MODIFIED="1368932246010" TEXT="eq name()"/>
</node>
<node CREATED="1368932271679" ID="ID_1050487841" MODIFIED="1368932335521" TEXT="static <T extends Enum<T>> T valueOf(Class<T> enumType, String name)"/>
</node>
<node CREATED="1368932370494" ID="ID_1042071650" MODIFIED="1368932394770" TEXT="static EnumType[] values()"/>
<node CREATED="1368932424102" FOLDED="true" ID="ID_1604431385" MODIFIED="1368932707779" TEXT="enum EnumType{VAL1(args),,VALN(args);...}">
<node CREATED="1368932628335" ID="ID_786286502" MODIFIED="1368932697889" TEXT="public static EnumType VAL1=new EnumType(args);"/>
</node>
</node>
<node CREATED="1345295576467" ID="ID_439912988" MODIFIED="1345295587763" TEXT="interface"/>
</node>
<node CREATED="1345184836953" FOLDED="true" ID="ID_673515131" MODIFIED="1366551705068" TEXT="method">
<node CREATED="1345184492421" ID="ID_265312513" MODIFIED="1345185136236" TEXT="arbitrary argnuments">
<icon BUILTIN="button_ok"/>
<node CREATED="1345184789892" ID="ID_1060258241" MODIFIED="1345184806144" TEXT="public static int sum(int... nums){/*...*/}"/>
</node>
<node CREATED="1345185138148" ID="ID_1463476592" MODIFIED="1345185151239" TEXT="default arguments">
<icon BUILTIN="button_cancel"/>
</node>
<node CREATED="1345185187246" ID="ID_1817646548" MODIFIED="1345185206154" TEXT="arguments passing">
<node CREATED="1345185208384" ID="ID_865348173" MODIFIED="1345185629944" TEXT="primitive types ">
<node CREATED="1345185770541" ID="ID_1967895996" MODIFIED="1345185779612" TEXT="stored in stack">
<node CREATED="1345185790107" ID="ID_658827170" MODIFIED="1345185801582" TEXT="passed by value"/>
</node>
</node>
<node CREATED="1345185630395" ID="ID_760637123" MODIFIED="1345185635435" TEXT="objects">
<node CREATED="1345185781533" ID="ID_551233070" MODIFIED="1345185787853" TEXT="stored in heap">
<node CREATED="1345185803731" ID="ID_1907310020" MODIFIED="1345185810875" TEXT="passed by ref"/>
</node>
</node>
</node>
</node>
<node CREATED="1344928722953" ID="ID_1038389453" MODIFIED="1379726732386" TEXT="nested class">
<node CREATED="1345196583960" ID="ID_1513693816" MODIFIED="1345196585766" TEXT="static">
<node CREATED="1345196617925" ID="ID_1771066606" MODIFIED="1379726791459">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<i>static nested classes</i>
</body>
</html></richcontent>
<node CREATED="1345198182349" ID="ID_1693378870" MODIFIED="1345198249874">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
a static nested class is behaviorally a top-level class that has been nested in another top-level class for packaging convenience.
</body>
</html></richcontent>
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1345198241858" ID="ID_243040733" MODIFIED="1345198276467" TEXT="A static nested class interacts with the instance members of its outer class (and other classes) just like any other top-level class.">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1345198345259" ID="ID_1169759482" MODIFIED="1345198352851" TEXT="As with class methods and variables, a static nested class is associated with its outer class. And like static class methods, a static nested class cannot refer directly to instance variables or methods defined in its enclosing class — it can use them only through an object reference">
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1345285184107" ID="ID_487792780" MODIFIED="1345285196045" TEXT="allmemberinterfacesareimplicitlystatic">
<icon BUILTIN="button_ok"/>
</node>
</node>
</node>
<node CREATED="1345196586010" ID="ID_802474804" MODIFIED="1345196588752" TEXT="non-static">
<node CREATED="1345196638124" ID="ID_162637877" MODIFIED="1345196638124">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<i>inner classes</i>
</body>
</html></richcontent>
<node CREATED="1345283004959" ID="ID_952925521" MODIFIED="1345284297618">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
an inner class is associated with an instance of its enclosing class and has direct access to that object's methods and fields.
</body>
</html></richcontent>
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1345283037210" ID="ID_1445262409" MODIFIED="1345284298783">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
because an inner class is associated with an instance, it cannot define any static members itself.
</body>
</html></richcontent>
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1345283172157" ID="ID_578357288" MODIFIED="1345284299792">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
Objects that are instances of an inner class exist <i>within</i> an instance of the outer class.
</body>
</html></richcontent>
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1345284272393" ID="ID_915374599" MODIFIED="1345284300715">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
An instance of <code>InnerClass</code> can exist only within an instance of <code>OuterClass</code> and has direct access to the methods and fields of its enclosing instance
</body>
</html></richcontent>
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1345284292903" ID="ID_399442280" MODIFIED="1345284302038">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
To instantiate an inner class, you must first instantiate the outer class. Then, create the inner object within the outer object with this syntax:
</p>
<div class="codeblock">
<pre>OuterClass.InnerClass innerObject = outerObject.new InnerClass();</pre>
</div>
</body>
</html></richcontent>
<icon BUILTIN="button_ok"/>
</node>
<node CREATED="1345284452375" ID="ID_837723876" MODIFIED="1345288064450">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
two special kinds of inner classes
</body>
</html></richcontent>
<icon BUILTIN="bookmark"/>
<node CREATED="1345284522392" ID="ID_1693016747" MODIFIED="1345284522392">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
local class
</body>
</html></richcontent>
</node>
<node CREATED="1345284524694" ID="ID_1867409150" MODIFIED="1345284530182" TEXT="anonymous class"/>
<node COLOR="#338800" CREATED="1345288071372" ID="ID_1471575167" MODIFIED="1345288198985" TEXT="enclosed by method ,constructor,initialization block">
<font BOLD="true" NAME="Dialog" SIZE="16"/>
<icon BUILTIN="button_ok"/>
</node>
</node>
</node>
</node>
</node>
</node>
<node CREATED="1344928759131" FOLDED="true" ID="ID_1211870260" MODIFIED="1368930540447" TEXT="Class">
<node CREATED="1344931520612" ID="ID_1728175622" MODIFIED="1344931538315" TEXT="Class.classForName()"/>
<node CREATED="1344931632714" ID="ID_481295074" MODIFIED="1344931657866" TEXT="Class.getSimpleName()"/>
<node CREATED="1344931538569" ID="ID_1621932834" MODIFIED="1344931567626" TEXT="Class.newInstance()"/>
<node CREATED="1344931568290" ID="ID_1594022608" MODIFIED="1344931632478" TEXT="<instance>.getClass()"/>
</node>
<node CREATED="1344928709477" ID="ID_230623101" MODIFIED="1417294412911" TEXT="generic programming">
<node CREATED="1344930897070" ID="ID_1089510991" MODIFIED="1344954136770" STYLE="fork" TEXT="parameterized type ensuring compile-time type safety">
<font NAME="Dialog" SIZE="16"/>
<node CREATED="1344930904905" ID="ID_1451160417" MODIFIED="1344954076567" TEXT="vs. ancestor Class Object as generic type (run-time error)"/>
<node CREATED="1344954377809" ID="ID_1826645959" MODIFIED="1344954380254" TEXT="Stronger type checks at compile time">
<node CREATED="1344954078438" ID="ID_622737985" MODIFIED="1344954390800" TEXT="compile-time error">
<node CREATED="1344954185524" ID="ID_800399872" MODIFIED="1344954199188" TEXT="compile-time type safety"/>
</node>
</node>
<node CREATED="1344954467059" ID="ID_1532243466" MODIFIED="1344954468690" TEXT="Elimination of casts"/>
<node CREATED="1344954530581" ID="ID_1624572204" MODIFIED="1344954533937" TEXT="Enabling programmers to implement generic algorithms"/>
</node>
<node CREATED="1344956619025" FOLDED="true" ID="ID_114329456" MODIFIED="1417294497268" TEXT="terminology">
<node CREATED="1344958622616" ID="ID_713811769" MODIFIED="1344958637468" TEXT="generic type"/>
<node CREATED="1344958637898" ID="ID_488144152" MODIFIED="1344958639860" TEXT="type value"/>
<node CREATED="1344958640315" ID="ID_1192302033" MODIFIED="1344958654197" TEXT="parameterized type"/>
<node CREATED="1344958654683" ID="ID_1723352583" MODIFIED="1344958691495" TEXT="type parameter"/>
<node CREATED="1344958669248" ID="ID_1100716939" MODIFIED="1344958700711" TEXT="type argument"/>
</node>
<node CREATED="1345085442768" ID="ID_74009324" MODIFIED="1345085464118" TEXT="type parameter">
<node CREATED="1345085466615" ID="ID_702184598" MODIFIED="1345085487199" TEXT="non-bounded type parameter">
<node CREATED="1345085571271" ID="ID_557958642" MODIFIED="1345085576297" TEXT="<T>"/>
</node>
<node CREATED="1345085487437" ID="ID_767819097" MODIFIED="1345085604638" TEXT="uni-bounded type parameter">
<node CREATED="1345085607329" ID="ID_1764962452" MODIFIED="1345085610205" TEXT="<U extends Number>"/>
</node>
<node CREATED="1345085519007" ID="ID_1023851440" MODIFIED="1345085561576" TEXT="multi-bounded type parameter">
<node CREATED="1345085637179" ID="ID_689089898" MODIFIED="1345085641341" TEXT="<T extends B1 & B2 & B3>">
<node CREATED="1345086159882" ID="ID_582279805" MODIFIED="1345086159882">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
A type variable with multiple bounds is a subtype of all the types listed in the bound. If one of the bounds is a class, it must be specified first.
</body>
</html></richcontent>
</node>
<node CREATED="1345086239855" ID="ID_789320482" MODIFIED="1345086316661" TEXT="first type is class or interface ,remaining types must be interfaces"/>
</node>
</node>
</node>
<node CREATED="1345087173283" ID="ID_237225749" MODIFIED="1345087176035" TEXT="Type Inference"/>
<node CREATED="1345087720988" ID="ID_1469374021" MODIFIED="1345087731035" TEXT="wildcard (?)">
<node CREATED="1345087748163" ID="ID_1099622293" MODIFIED="1345087758402" TEXT="Upper Bounded Wildcards">
<node CREATED="1345087772515" ID="ID_199697537" MODIFIED="1345087772515">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>public static void process(List<strong><? extends Foo></strong> list) { /* ... */ }</pre>
</body>
</html></richcontent>
</node>
</node>
<node CREATED="1345087786440" ID="ID_817249988" MODIFIED="1345087788827" TEXT="Unbounded Wildcards">
<node CREATED="1345087816474" ID="ID_1334761492" MODIFIED="1345087816474">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>public static void printList(List<?> list) {
for (Object elem: list)
System.out.print(elem + " ");
System.out.println();
}</pre>
</body>
</html></richcontent>
</node>
</node>
<node CREATED="1345087882683" ID="ID_389992684" MODIFIED="1345087884549" TEXT="Lower Bounded Wildcards">
<node CREATED="1345087907035" ID="ID_517802201" MODIFIED="1345087907035">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>public static void addNumbers(List<? super Integer> list) {
for (int i = 1; i <= 10; i++) {
list.add(i);
}
}</pre>
</body>
</html></richcontent>
</node>
</node>
</node>
<node CREATED="1345086652255" ID="ID_639758981" MODIFIED="1345086655019" TEXT="Given two concrete types A and B (for example, Number and Integer), MyClass<A> has no relationship to MyClass<B>, regardless of whether or not A and B are related. The common parent of MyClass<A> and MyClass<B> is Object."/>
<node CREATED="1344955211070" ID="ID_1544930650" MODIFIED="1344959028062" TEXT="generic class/interface">
<node CREATED="1344959035033" ID="ID_1416787328" MODIFIED="1344959039644" TEXT="definition">
<node CREATED="1344955235578" FOLDED="true" ID="ID_240644656" MODIFIED="1345082968830">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>class name<T1, T2, ..., Tn> { /* ... */ }</pre>
</body>
</html></richcontent>
<node COLOR="#ff0000" CREATED="1344956854645" ID="ID_427839111" MODIFIED="1344956895665">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
A type variable can be any <strong>non-primitive</strong> type
</body>
</html></richcontent>
<font NAME="Dialog" SIZE="16"/>
<icon BUILTIN="full-1"/>
</node>
<node CREATED="1345082894620" FOLDED="true" ID="ID_1262216653" MODIFIED="1345082967020" TEXT="A raw type is the name of a generic class or interface without any type arguments">
<icon BUILTIN="full-2"/>
<node CREATED="1344956899832" ID="ID_348418350" MODIFIED="1345082956973" TEXT="if type argument is not specified,Object will be the argument">
<node CREATED="1344957061949" ID="ID_1046288329" MODIFIED="1344957772936" TEXT="Object ref can be assigned to primitive types which are automatically cast into wrapper class ,e.g. int->java.lang.Integer"/>
</node>
</node>
</node>
</node>
<node CREATED="1344959043870" ID="ID_1886365364" MODIFIED="1344959080073" TEXT="instantiation">
<node CREATED="1344959111573" ID="ID_172593929" MODIFIED="1344959155177" TEXT="ClassName<Integer> intobj = new ClassName<Integer>(...)"/>
</node>
</node>
<node CREATED="1345083843519" ID="ID_82476767" MODIFIED="1509194663522" TEXT="generic method">
<node CREATED="1345083859888" ID="ID_1987882782" MODIFIED="1345083912091" TEXT="definition">
<node CREATED="1345083888600" ID="ID_1165801600" MODIFIED="1345083888600">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>public class Util {
// Generic static method
<strong>public static <K, V> boolean compare(Pair<K, V> p1, Pair<K, V> p2)</strong> {
return p1.getKey().equals(p2.getKey()) &&
p1.getValue().equals(p2.getValue());
}
}</pre>
</body>
</html></richcontent>
</node>
</node>
<node CREATED="1345083913033" ID="ID_1483245486" MODIFIED="1509194822710" TEXT="invocation">
<node CREATED="1345083934577" ID="ID_1645009380" MODIFIED="1509194868650">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>Pair<Integer, String> p1 = new Pair<>(1, "apple");
Pair<Integer, String> p2 = new Pair<>(2, "pear");
boolean same = Util.<strong><Integer, String></strong>compare(p1, p2);</pre>
</body>
</html></richcontent>
<font NAME="Nimbus Roman" SIZE="12"/>
</node>
</node>
</node>
<node CREATED="1344958497215" FOLDED="true" ID="ID_1882822317" MODIFIED="1509194886364" TEXT="Type Parameter Naming Conventions">
<node CREATED="1344958533229" ID="ID_545719924" MODIFIED="1344958533229">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<ul>
<li>
E - Element (used extensively by the Java Collections Framework)
</li>
<li>
K - Key
</li>
<li>
N - Number
</li>
<li>
T - Type
</li>
<li>
V - Value
</li>
<li>
S,U,V etc. - 2nd, 3rd, 4th types
</li>
</ul>
</body>
</html></richcontent>
</node>
</node>
</node>
<node CREATED="1345299239016" ID="ID_274384869" MODIFIED="1558423084881" TEXT="annotation">
<node CREATED="1345299262691" ID="ID_689043907" MODIFIED="1363773949965">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
</p>
</body>
</html></richcontent>
<icon BUILTIN="wizard"/>
<node CREATED="1345299807485" ID="ID_1442500037" MODIFIED="1345299807485">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
<em>Annotations</em> provide data about a program that is not part of the program itself. They have no direct effect on the operation of the code they annotate.
</p>
</body>
</html></richcontent>
</node>
</node>
<node CREATED="1345299602837" ID="ID_748037325" MODIFIED="1345299817963">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
</body>
</html></richcontent>
<icon BUILTIN="wizard"/>
<node CREATED="1345299820389" ID="ID_786888988" MODIFIED="1345299820389">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
Annotations can be applied to a program's declarations of <b>classes</b>, <b>fields</b>, <b>methods</b>, and <b>other program elements</b>.
</p>
</body>
</html></richcontent>
</node>
</node>
<node CREATED="1345299304783" FOLDED="true" ID="ID_1156962674" MODIFIED="1558424425366" TEXT="3 functions">
<node CREATED="1345299328959" ID="ID_136280043" MODIFIED="1345299354455">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<b>Information for the compiler</b>
</body>
</html></richcontent>
<icon BUILTIN="full-1"/>
<node CREATED="1345299343384" ID="ID_842878963" MODIFIED="1345302957339">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
Annotations can be used by the compiler to detect errors or suppress warnings.
</body>
</html></richcontent>
<font NAME="Dialog" SIZE="16"/>
<icon BUILTIN="wizard"/>
</node>
<node CREATED="1345302508710" ID="ID_31638783" MODIFIED="1363774044604" TEXT="3 ">
<node CREATED="1345302542518" ID="ID_1163888116" MODIFIED="1345302605192">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<b>@Deprecated</b>
</body>
</html></richcontent>
<icon BUILTIN="full-1"/>
</node>
<node CREATED="1345302558828" ID="ID_276605916" MODIFIED="1345302607885">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<b>@Override</b>
</body>
</html></richcontent>
<icon BUILTIN="full-2"/>
</node>
<node CREATED="1345302578605" ID="ID_1008202394" MODIFIED="1558423160778">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<b>@SuppressWarnings</b>
</body>
</html></richcontent>
<icon BUILTIN="full-3"/>
<node CREATED="1345302821737" ID="ID_1967201983" MODIFIED="1345302968291">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>@SuppressWarnings("deprecation")</pre>
</body>
</html></richcontent>
<font NAME="Dialog" SIZE="16"/>
</node>
<node CREATED="1345302949554" ID="ID_463811006" MODIFIED="1345302949554">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>@SuppressWarnings({"unchecked", "deprecation"})</pre>
</body>
</html></richcontent>
</node>
<node CREATED="1345302821737" ID="ID_1373734627" MODIFIED="1345303003186">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>@SuppressWarnings("unchecked")</pre>
</body>
</html></richcontent>
<font NAME="Dialog" SIZE="16"/>
</node>
</node>
</node>
</node>
<node CREATED="1345299367158" ID="ID_1932329091" MODIFIED="1345299370234">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<b>Compiler-time and deployment-time processing</b>
</body>
</html></richcontent>
<icon BUILTIN="full-2"/>
<node CREATED="1345299383200" ID="ID_203105368" MODIFIED="1345299434537">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
Software tools can process annotation information to generate code, XML files, and so forth.
</body>
</html></richcontent>
<icon BUILTIN="wizard"/>
</node>
<node CREATED="1345303290028" ID="ID_102168388" MODIFIED="1345303312367">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
<code><font size="5">@Retention(RetentionPolicy.RUNTIME)</font></code>
</p>
</body>
</html></richcontent>
<node CREATED="1345303323128" ID="ID_370936389" MODIFIED="1345303325905" TEXT="apt"/>
</node>
</node>
<node CREATED="1345299395031" ID="ID_881645397" MODIFIED="1345299400235">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<b>Runtime processing</b>
</body>
</html></richcontent>
<icon BUILTIN="full-3"/>
<node CREATED="1345299415249" ID="ID_1847911239" MODIFIED="1345299438610">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
Some annotations are available to be examined at runtime.
</body>
</html></richcontent>
<icon BUILTIN="wizard"/>
</node>
</node>
</node>
<node CREATED="1345300123053" FOLDED="true" ID="ID_561722797" MODIFIED="1558424423922" TEXT="annotation type">
<node CREATED="1345300232551" ID="ID_505942422" MODIFIED="1345300427380">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<p>
<b>@interface </b>AnnotationType{/*...*/}
</p>
</body>
</html></richcontent>
<node CREATED="1345300222577" ID="ID_917307181" LINK="#ID_119178843" MODIFIED="1345300556818">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>@interface ClassPreamble {
String author();
String date();
int currentRevision() default 1;
String lastModified() default "N/A";
String lastModifiedBy() default "N/A";
// Note use of array
String[] reviewers();
}</pre>
</body>
</html></richcontent>
</node>
</node>
<node CREATED="1345300336007" ID="ID_996596687" MODIFIED="1345300413679" TEXT="annotation type element">
<node CREATED="1345300357207" ID="ID_828705575" MODIFIED="1345300365239">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre> String author();
String date();</pre>
</body>
</html></richcontent>
</node>
</node>
<node CREATED="1345300367296" ID="ID_431261225" MODIFIED="1363773919276" TEXT="default value">
<node CREATED="1345300397685" ID="ID_211273692" MODIFIED="1345300407478">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>String lastModified() default "N/A";
String lastModifiedBy() default "N/A";</pre>
</body>
</html></richcontent>
</node>
</node>
</node>
<node CREATED="1345299682831" FOLDED="true" ID="ID_518620445" MODIFIED="1558424419647" TEXT="using annotations">
<node CREATED="1345299832551" ID="ID_211797337" MODIFIED="1345299836988" TEXT="">
<icon BUILTIN="full-1"/>
<node CREATED="1345299719929" ID="ID_167062999" MODIFIED="1363774157483">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>@Author(
name = "Benjamin Franklin",
date = "3/27/2003"
)
class MyClass() { }</pre>
</body>
</html></richcontent>
<node CREATED="1345299771778" ID="ID_1217234703" MODIFIED="1345299774324" TEXT="The annotation appears first, often (by convention) on its own line, and may include elements with named or unnamed values."/>
</node>
</node>
<node CREATED="1345299841624" ID="ID_808403742" MODIFIED="1345299846375" TEXT="">
<icon BUILTIN="full-2"/>
<node CREATED="1345299870680" ID="ID_158087893" MODIFIED="1345299870680">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>@SuppressWarnings(value = "unchecked")
void myMethod() { }</pre>
</body>
</html></richcontent>
</node>
<node CREATED="1345299892772" ID="ID_1259266597" MODIFIED="1363774174469">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
<pre>@SuppressWarnings("unchecked")
void myMethod() { }</pre>
</body>
</html></richcontent>
<node CREATED="1345299914403" ID="ID_1845523552" MODIFIED="1345299914403">
<richcontent TYPE="NODE"><html>
<head>
</head>
<body>
If there is just one element named "value," then the name may be omitted
</body>
</html></richcontent>
</node>
</node>
</node>
<node CREATED="1345299922249" ID="ID_1917452954" MODIFIED="1345299926225" TEXT="">