java经典源代码(Java classic source code) Remember to format Java when you save this kind of code! ------------------------------------------------ Class HelloWorld { Public native void displayHelloWorld (); Static { ("hello"); } Public static void main (String[] args) { New HelloWorld ().DisplayHelloWorld (); } } ------------------------------------------------ Interface VideoCard { Void Display (); String getName (); } ------------------------------------------------ Interface Sport { Void run (); Void jump (); } Class Athlete implements Sport { Public void run () { (Sprint); } Public void jump () { ("three jump"); } Public static void main (String[] args) { Athlete zhangsan=new Athlete (); (); (); } } ------------------------------------------------ puter { Public static void main (String[] args) { Dmeng d=new Dmeng (); Mainboard m=new Mainboard (); ("Intel's CPU"); (D); (); } } ------------------------------------------------ Class Car { Class Wheel { } } Class PlaneWheel extends { PlaneWheel (Car car) { (); } Public static void main (String[] args) { Car car=new Car (); PlaneWheel pw=new PlaneWheel (car); } } ------------------------------------------------ Class A { Void FN1 () { } } Abstract class B { Abstract void FN2 (); } Class C extends A { B getB () { Return new B () { Public void FN2 () { } }; } } Class Test { Static void method1 (A a) { (); } Static void method2 (B b) { (); } Public static void main (String[] args) { C c=new C (); Method1 (C); Method2 ( ()); } } ------------------------------------------------ Class Animal { Int height, weight; Animal (int height, int weight) { / / ("animal construct"); } Void eat () { ("animal eat"); } Void sleep (