<!--
/* Font Definitions */
@font-face
{font-family:宋體;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:黑體;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimHei;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:1 135135232 16 0 262144 0;}
@font-face
{font-family:"\@黑體";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:1 135135232 16 0 262144 0;}
@font-face
{font-family:"\@宋體";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋體;
mso-font-kerning:1.0pt;}
h1
{mso-style-next:本文;
margin-top:17.0pt;
margin-right:0cm;
margin-bottom:16.5pt;
margin-left:21.25pt;
text-align:justify;
text-justify:inter-ideograph;
text-indent:-21.25pt;
line-height:240%;
mso-pagination:lines-together;
page-break-after:avoid;
mso-outline-level:1;
mso-list:l1 level1 lfo1;
tab-stops:list 21.25pt;
font-size:22.0pt;
font-family:"Times New Roman";
mso-font-kerning:22.0pt;}
h2
{mso-style-next:本文;
margin-top:13.0pt;
margin-right:0cm;
margin-bottom:13.0pt;
margin-left:1.0cm;
text-align:justify;
text-justify:inter-ideograph;
text-indent:-1.0cm;
line-height:173%;
mso-pagination:lines-together;
page-break-after:avoid;
mso-outline-level:2;
mso-list:l1 level2 lfo1;
tab-stops:list 1.0cm;
font-size:16.0pt;
font-family:Arial;
mso-fareast-font-family:黑體;
mso-bidi-font-family:"Times New Roman";
mso-font-kerning:1.0pt;}
h3
{mso-style-next:本文;
margin-top:13.0pt;
margin-right:0cm;
margin-bottom:13.0pt;
margin-left:0cm;
text-align:justify;
text-justify:inter-ideograph;
line-height:173%;
mso-pagination:lines-together;
page-break-after:avoid;
mso-outline-level:3;
font-size:16.0pt;
font-family:"Times New Roman";
mso-font-kerning:1.0pt;}
p.4, li.4, div.4
{mso-style-name:"樣式 標題 4";
mso-style-parent:"標題 3";
margin-top:13.0pt;
margin-right:0cm;
margin-bottom:13.0pt;
margin-left:35.45pt;
text-align:justify;
text-justify:inter-ideograph;
text-indent:-35.45pt;
line-height:173%;
mso-pagination:lines-together;
page-break-after:avoid;
mso-outline-level:3;
mso-list:l1 level3 lfo1;
tab-stops:list 35.45pt;
font-size:15.0pt;
mso-bidi-font-size:16.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋體;
font-weight:bold;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
/* List Definitions */
@list l0
{mso-list-id:1147820946;
mso-list-type:hybrid;
mso-list-template-ids:-539340266 287331220 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-tab-stop:18.0pt;
mso-level-number-position:left;
margin-left:18.0pt;
text-indent:-18.0pt;}
@list l1
{mso-list-id:1390962552;
mso-list-template-ids:1939346452;}
@list l1:level1
{mso-level-style-link:"標題 1";
mso-level-tab-stop:21.25pt;
mso-level-number-position:left;
margin-left:21.25pt;
text-indent:-21.25pt;}
@list l1:level2
{mso-level-style-link:"標題 2";
mso-level-text:"%1\.%2\.";
mso-level-tab-stop:1.0cm;
mso-level-number-position:left;
margin-left:1.0cm;
text-indent:-1.0cm;}
@list l1:level3
{mso-level-style-link:"樣式 標題 4";
mso-level-text:"%1\.%2\.%3\.";
mso-level-tab-stop:35.45pt;
mso-level-number-position:left;
margin-left:35.45pt;
text-indent:-35.45pt;}
@list l1:level4
{mso-level-text:"%1\.%2\.%3\.%4\.";
mso-level-tab-stop:42.55pt;
mso-level-number-position:left;
margin-left:42.55pt;
text-indent:-42.55pt;}
@list l1:level5
{mso-level-text:"%1\.%2\.%3\.%4\.%5\.";
mso-level-tab-stop:49.6pt;
mso-level-number-position:left;
margin-left:49.6pt;
text-indent:-49.6pt;}
@list l1:level6
{mso-level-text:"%1\.%2\.%3\.%4\.%5\.%6\.";
mso-level-tab-stop:2.0cm;
mso-level-number-position:left;
margin-left:2.0cm;
text-indent:-2.0cm;}
@list l1:level7
{mso-level-text:"%1\.%2\.%3\.%4\.%5\.%6\.%7\.";
mso-level-tab-stop:63.8pt;
mso-level-number-position:left;
margin-left:63.8pt;
text-indent:-63.8pt;}
@list l1:level8
{mso-level-text:"%1\.%2\.%3\.%4\.%5\.%6\.%7\.%8\.";
mso-level-tab-stop:70.9pt;
mso-level-number-position:left;
margin-left:70.9pt;
text-indent:-70.9pt;}
@list l1:level9
{mso-level-text:"%1\.%2\.%3\.%4\.%5\.%6\.%7\.%8\.%9\.";
mso-level-tab-stop:77.95pt;
mso-level-number-position:left;
margin-left:77.95pt;
text-indent:-77.95pt;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
-->
1.1.
內嵌類
1.1.1.
代碼
/*
* To
change this template, choose Tools | Templates
*
and open the template in the editor.
*/
package javatutorials;
/**
*
*
@author wanpor
*/
public class InnerClass {
public static void main(String[] args){
//
建立靜態內嵌類
InnerClass.A ica
= new InnerClass.A();
ica.printInfo();
//
建立非靜態內嵌類
InnerClass b = new InnerClass();
InnerClass.B icb = b.new B();
icb.printInfo();
}
//
靜態內嵌類
public static class A{
static void printInfo(){
System.out.println("A");
}
}
//
非靜態內嵌類
public class B{
void printInfo(){
System.out.println("B");
}
}
}
1.1.2.
說明
1.
定義靜態內嵌類;
2.
定義非靜態內嵌類
3.
建立靜態內嵌類對象
4.
建立非靜態內嵌類對象
靜態類不能執行個體化,類的成員都要是靜態成員和靜態方法,
非靜態類一般需要執行個體化後才可以操作,不過介面和抽像類不能直接執行個體化。