时间:2011-07-20
3)我的测试程序FinalDemo.java
package zy.pro.jbd.demo;
/**
* this demo is created to test the usage of the final reserved word
*/
import zy.pro.jbd.testbase.A;
public class FinalDemo {
final int numInt1 = 16;
final String str = "zy";
final String str1;
final A a = new A();
public FinalDemo() {
str1 = "zy";
}
public static void main(String[] args) {
System.out.println("-------------------------------------------------");
FinalDemo fd = new FinalDemo();
fd.executeFinalTest();
}
public void executeFinalTest() {
this.testFinalInt();
this.testFinalString();
this.testFinalObject();
}
private void testFinalInt() {
//numInt1+=1;
System.out.println(numInt1);
}
private void testFinalString() {
//str=str+"aaaaa";
System.out.println(str);
}
public void testFinalObject() {
a.setT(29);
System.out.println("t: " + a.getT());
/*
* some error will be threw
A b=new A();
a=b;
*/
}
}
|