您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 冶金工业 > java技术专题综述之内部类篇
JAVA(innerclass)publicclassOuterClass{publicclassInnerClass{//---Thisisainnerclass.}}InnerClassOuterClasspublicOuterClassInnerClassOuterClassOuterClassInnerClass1classOuterClass{classInnerClass{}}publicclassTest{publicstaticvoidmain(String[]args){OuterClassout=newOuterClass();OuterClass.InnerClassin=out.newInnerClass();}}OuterClassout=newOuterClass();OuterClassOuterClass.InnerClassin=out.newInnerClass();main()OuterClass.InnerClassin=newOuterClass().newInnerClass();(Test)(OuterClass)(InnerClass)(OuterClass)OuterClass.InnerClass2publicclassTest{classInnerClass{}1publicstaticvoidmain(String[]args){InnerClassin=newTest().newInnerClass();}}main()3publicclassTest{classInnerClass{}InnerClassin=newInnerClass();publicstaticvoidmain(String[]args){}}main()4publicclassTest{classInnerClass{}publicvoidmethod(){InnerClassin=newInnerClass();}publicstaticvoidmain(String[]args){}}static5classOuterClass{staticclassInnerClass{}}publicclassTest{publicstaticvoidmain(String[]args){2OuterClass.InnerClassin=newOuterClass.InnerClass();}}InnerClassOuterClassOuterClass.InnerClassin6classOuter{staticintouter_stat=0;intouter_non_stat=1;staticclassStaticInner{staticintstat=2;staticintstat_test=outer_stat;publicvoidtester(){System.out.println(outer_stat=+outer_stat);}}classNonStaticInner{publicvoidtester(){System.out.println(outer_stat=+outer_stat);System.out.println(outer_non_stat=+outer_non_stat);System.out.println(StaticInner.stat=+StaticInner.stat);}}}publicclassTest{publicstaticvoidmain(String[]args){newOuter().newNonStaticInner().tester();System.out.println(------------);newOuter.StaticInner().tester();}}outer_stat=0outer_non_stat=1StaticInner.stat=23------------outer_stat=0NonStaticInnerSystem.out.println(outer_stat=+outer_stat);System.out.println(outer_non_stat=+outer_non_stat);System.out.println(StaticInner.stat=+StaticInner.stat);StaticInnerSystem.out.println(outer_stat=+outer_stat);staticintstat_test=outer_stat;7classOuter{publicvoidtester(){classInner{}}}publicclassTest{publicstaticvoidmain(String[]args){}}final88classOuter{publicvoidtester(){finalinti=5;classInner{intj=i;4}Innerin=newInner();}}publicclassTest{publicstaticvoidmain(String[]args){}}SUN44public,protected,private,static8;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassTestextendsJFrame{Test(){super(test_title);Containercp=getContentPane();cp.setLayout(newFlowLayout());JButtonbtn=newJButton(close);cp.add(btn);btn.addActionListener(act);setSize(300,200);}ActionListeneract=newActionListener(){publicvoidactionPerformed(ActionEvente)5{System.exit(0);}};publicstaticvoidmain(String[]args){Testtest=newTest();test.setVisible(true);}}98importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassTestextendsJFrame{Test(){super(test_title);Containercp=getContentPane();cp.setLayout(newFlowLayout());JButtonbtn=newJButton(close);cp.add(btn);btn.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){System.exit(0);}});}publicstaticvoidmain(String[]args){Testtest=newTest();test.setSize(300,200);test.setVisible(true);}}10publicclassTest{publicstaticvoidmain(String[]args)6{Threadr=newThread(){publicvoidrun(){for(intk=0;k10;k++){System.out.print(k);}}};r.start();}}1110publicclassTest{publicstaticvoidmain(String[]args){newThread(newRunnable(){publicvoidrun(){System.out.println(run);}}).start();}}1011SCJP/MCSE/MCDBAxmjemail@yahoo.com.cn2002.97
本文标题:java技术专题综述之内部类篇
链接地址:https://www.777doc.com/doc-7004857 .html