1、Java 就业培训教程张孝祥_书内源码(全).txt 爱空空情空空,自己流浪在街中;人空空钱空空,单身苦命在打工;事空空业空空,想来想去就发疯;碗空空盆空空,生活所迫不轻松。总之,四大皆空!这个有声教程是著名中国 IT 培训老师张孝祥编写,和清华大学出版社发行的Java 就业培训教程配套的。Quick GuideThis is the Chalk Training Video CD for Edit by ZHANG XiaoXiang, the famous top training teacher in China.Copyright WWW.it315.org,2003-2005Plea
2、se use RealOne Player V2 Gold to play it.(You can download this player from http:/)For the best video effect, we strongly suggest that you set the resolvtion to at least 1024 x 768 x256and watch it in the full-screen mode.=简要说明中国最著名的 IT 培训教师张孝祥编著的Java 就业培训教程配套光盘教学软件,其中的所有视频教学录象文件均为 RMVB 格式。版权所有:WWW.
3、it315.org (2003-2005)请使用 RealOnePlayerV2GOLD 播放器进行播放。(你可登陆 http:/ 下载该软件,也可通过网络查找后下载。 )为了达到最佳显示效果请将您的计算机显示分辨率设置为 1024*768,并在全屏模式下观看。Java 就业培训教程 作者:张孝祥 书中源码 Java 就业培训教程P34 源码程序清单:Promote.javaclass Promote public static void main(String args) byte b = 50;char c = a;short s = 1024;int i = 50000;float f
4、= 5.67f;double d = .1234;double result = (f * b) + (i / c) - (d * s);System.out.println(f * b) + “ + “ + (i / c) + “ - “ + (d * s);System.out.println(“result = “ + result);Java 就业培训教程P35 源码程序清单:TestScope.javapublic class TestScopepublic static void main(String args)int x = 12; int q = 96; / x 和 q 都可
5、用System.out.println(“x is “+x); System.out.println(“q is “+q);q = x; /* 错误的行,只有 x 可用, q 超出了作用域范围 */System.out.println(“x is “+x); Java 就业培训教程P37 源码程序清单:TestVar.javapublic class TestVarpublic static void main(String args)int x;/应改为 int x=0;x=x+1; /这个 x 由于没有初始化,编译会报错。System.out.println(“x is “+x);程序清单
6、:Func1.javapublic class Func1public static void main(String args)/* 下面是打印出第一个矩形的程序代码*/for(int i=0;i1;y=y1;System.out.println(“0x800000001 = “ + Integer.toHexString(x);System.out.println(“0x800000001 = “ + Integer.toHexString(y);Java 就业培训教程P61 源码程序清单:TestDo.javapublic class TestDopublic static void m
7、ain(String args)int x=3;while(x=0)System.out.println(“ok1“);x+;int y=3;doSystem.out.println(“ok2“);y+;while(y=0);Java 就业培训教程P64 源码程序清单:PrintOddNum.javapublic class PrintOddNumpublic static void main(String args)for(int i=0;i1;y=y1;System.out.println(“0x800000001 = “ + Integer.toHexString(x);System.o
8、ut.println(“0x800000001 = “ + Integer.toHexString(y);Java 就业培训教程P61 源码程序清单:TestDo.javapublic class TestDopublic static void main(String args)int x=3;while(x=0)System.out.println(“ok1“);x+;int y=3;doSystem.out.println(“ok2“);y+;while(y=0);Java 就业培训教程P64 源码程序清单:PrintOddNum.javapublic class PrintOddNum
9、public static void main(String args)for(int i=0;i130)return;age = i; public int getAge() return age;public class TestPersonpublic static void main(String args)Person p1 = new Person();p1.setAge(3);p1.setAge(-6);System.out.println(p1.getAge();Java 就业培训教程P88 源码class Personpublic Person()System.out.pri
10、ntln(“the constructor 1 is calling!“);private int age = 10;public void shout()System.out.println(“age is “+age); class TestPersonpublic static void main(String args)Person p1=new Person();p1.shout();Person p2=new Person();p2.shout();Person p3=new Person();p3.shout();Java 就业培训教程P90 源码class Personpriv
11、ate String name=“unknown“;private int age = -1;public Person()System.out.println(“constructor1 is calling“);public Person(String n)name = n;System.out.println(“constructor2 is calling“);System.out.println(“name is “+name);public Person(String n,int a)name = n;age = a;System.out.println(“constructor3
12、 is calling“);System.out.println(“name and age is “+name+“;“+age);public void shout()System.out.println(“listen to me!“); class TestPersonpublic static void main(String args)Person p1=new Person();P1.shout();Person p2=new Person(“Jack“);P2.shout();Person p3=new Person(“Tom“,18);P3.shout();Java 就业培训教
13、程P94 源码class Personprivate Person()System.out.println(“the constructor 1 is calling!“);class TestPersonpublic static void main(String args)Person p1=new Person();Java 就业培训教程P95 源码class AString name;public A(String x)name = x; public void func1()System.out.println(“func1 of “ + name +“ is calling“);p
14、ublic void func2()A a2 = new A(“a2“);a2.func1();class TestApublic static void main(String args)A a1 = new A(“a1“);a1.func2();Java 就业培训教程P96 源码class AString name;public A(String x)name = x; public void func1()System.out.println(“func1 of “ + name +“ is calling“);public void func2()A a2 = new A(“a2“);
15、this.func1();/使用 this 关键字调用 func1 方法a2.func1();Java 就业培训教程P99 源码class ContainerComponent comp;public void addComponent()comp = new Component(this);/将 this 作为对象引用传递class ComponentContainer myContainer;public Component(Container c)myContainer = c;Java 就业培训教程P100 源码public class PersonString name;int ag
16、e;public Person(String name)this.name = name;public Person(String name,int age)this(name);this.age = age; Java 就业培训教程P101 源码class Personpublic void finalize()System.out.println(“the object is going!“);public static void main(String args)new Person();new Person();new Person();System.out.println(“the
17、program is ending!“);Java 就业培训教程P103 源码class PassValuepublic static void main(String args)int x = 5;change(x);System.out.println(x);public static void change(int x)x = 3;class PassRefint x ;public static void main(String args)PassRef obj = new PassRef();obj.x = 5;change(obj);System.out.println(obj.x
18、);public static void change(PassRef obj)obj.x=3;Java 就业培训教程P108 源码class Chinesestatic String country=“中国“;String name;int age;void singOurCountry()System.out.println(“啊!,亲爱的“ + country);/类中的成员方法也可以直接访问静态成员变量class TestChinesepublic Static void main(String args)System.out.println(“Chinese country is “
19、 + Chinese.country);/上面的程序代码直接使用了“类名.成员“的格式Chinese ch1 = new Chinese();System.out.println(“Chines country is “ + ch1.country);/上面的程序代码直接使用了“对象名.成员“的格式ch1.singOurCountry();Java 就业培训教程P111 源码class StaticCodestatic String country;staticcountry = “china“;System.out.println(“StaticCode is loading“);class
20、 TestStaticCodestaticSystem.out.println(“TestStaticCode is loading“);public static void main(String args)System.out.println(“begin executing main method“);new StaticCode();new StaticCode();Java 就业培训教程P115 源码class Outerint outer_i = 100;void test()Inner in = new Inner();in.display();class Innervoid d
21、isplay()System.out.println(“display: outer_i = “ + outer_i);class InnerClassDemopublic static void main(String args)Outer outer = new Outer();outer.test();下载所得:Java 就业培训教程P81 源码class Comparepublic static void main(String args)String str1 = new String(“abc“);String str2 = new String(“abc“);String str
22、3 = str1;if(str1=str2)System.out.println(“str1=str2“);elseSystem.out.println(“str1!=str2“);if(str1=str3)System.out.println(“str1=str3“);elseSystem.out.println(“str1!=str3“);Java 就业培训教程P82 源码class Comparepublic static void main(String args)String str1 = new String(“abc“);String str2 = new String(“abc
23、“);String str3 = str1;if(str1.equals(str2)System.out.println(“str1 equal str2“);elseSystem.out.println(“str1 not equal str2“);if(str1.equals(str3)System.out.println(“str1 equal str3“);elseSystem.out.println(“str1 not equal str3“);Java 就业培训教程P86 源码class Personprivate int age;public void setAge(int i)
24、if(i130)return;age = i; public int getAge() return age;public class TestPersonpublic static void main(String args)Person p1 = new Person();p1.setAge(3);p1.setAge(-6);System.out.println(p1.getAge();Java 就业培训教程P88 源码class Personpublic Person()System.out.println(“the constructor 1 is calling!“);private
25、 int age = 10;public void shout()System.out.println(“age is “+age); class TestPersonpublic static void main(String args)Person p1=new Person();p1.shout();Person p2=new Person();p2.shout();Person p3=new Person();p3.shout();Java 就业培训教程P90 源码class Personprivate String name=“unknown“;private int age = -
26、1;public Person()System.out.println(“constructor1 is calling“);public Person(String n)name = n;System.out.println(“constructor2 is calling“);System.out.println(“name is “+name);public Person(String n,int a)name = n;age = a;System.out.println(“constructor3 is calling“);System.out.println(“name and ag
27、e is “+name+“;“+age);public void shout()System.out.println(“listen to me!“); class TestPersonpublic static void main(String args)Person p1=new Person();P1.shout();Person p2=new Person(“Jack“);P2.shout();Person p3=new Person(“Tom“,18);P3.shout();Java 就业培训教程P94 源码class Personprivate Person()System.out
28、.println(“the constructor 1 is calling!“);class TestPersonpublic static void main(String args)Person p1=new Person();Java 就业培训教程P95 源码class AString name;public A(String x)name = x; public void func1()System.out.println(“func1 of “ + name +“ is calling“);public void func2()A a2 = new A(“a2“);a2.func1
29、();class TestApublic static void main(String args)A a1 = new A(“a1“);a1.func2();Java 就业培训教程P96 源码class AString name;public A(String x)name = x; public void func1()System.out.println(“func1 of “ + name +“ is calling“);public void func2()A a2 = new A(“a2“);this.func1();/使用 this 关键字调用 func1 方法a2.func1(
30、);Java 就业培训教程P99 源码class ContainerComponent comp;public void addComponent()comp = new Component(this);/将 this 作为对象引用传递class ComponentContainer myContainer;public Component(Container c)myContainer = c;Java 就业培训教程P100 源码public class PersonString name;int age;public Person(String name)this.name = name;
31、public Person(String name,int age)this(name);this.age = age; Java 就业培训教程P101 源码class Personpublic void finalize()System.out.println(“the object is going!“);public static void main(String args)new Person();new Person();new Person();System.out.println(“the program is ending!“);Java 就业培训教程P103 源码class
32、PassValuepublic static void main(String args)int x = 5;change(x);System.out.println(x);public static void change(int x)x = 3;class PassRefint x ;public static void main(String args)PassRef obj = new PassRef();obj.x = 5;change(obj);System.out.println(obj.x);public static void change(PassRef obj)obj.x
33、=3;Java 就业培训教程P108 源码class Chinesestatic String country=“中国“;String name;int age;void singOurCountry()System.out.println(“啊!,亲爱的“ + country);/类中的成员方法也可以直接访问静态成员变量class TestChinesepublic Static void main(String args)System.out.println(“Chinese country is “ + Chinese.country);/上面的程序代码直接使用了“类名.成员“的格式Ch
34、inese ch1 = new Chinese();System.out.println(“Chines country is “ + ch1.country);/上面的程序代码直接使用了“对象名.成员“的格式ch1.singOurCountry();Java 就业培训教程P111 源码class StaticCodestatic String country;staticcountry = “china“;System.out.println(“StaticCode is loading“);class TestStaticCodestaticSystem.out.println(“Test
35、StaticCode is loading“);public static void main(String args)System.out.println(“begin executing main method“);new StaticCode();new StaticCode();Java 就业培训教程P115 源码class Outerint outer_i = 100;void test()Inner in = new Inner();in.display();class Innervoid display()System.out.println(“display: outer_i
36、= “ + outer_i);class InnerClassDemopublic static void main(String args)Outer outer = new Outer();outer.test();Java 就业培训教程 作者:张孝祥 书中源码 Java 就业培训教程P127 源码程序清单:Student.javaclass Person public String name;public int age;public Person(String name,int age)this.name=name;this.age=age;public Person() /如果不写这
37、个构造函数,看看对类 Student 有什么影响。public void getInfo() System.out.println(name); System.out.println(age); class Student extends Personpublic void study()System.out.println(“Studding“);public static void main(String args)Person p=new Person();p.name=“person“;p.age=30;p.getInfo();Student s=new Student();s.name=“student“;s.age=16;s.getInfo();s.study();Java 就业培训教程P135 源码interface Animal extends Runnervoid breathe();class Fish implements Animalpublic void run()System.out.println(“fish is swimming“);public void breathe()