當 java 執行時會 load statictest 建立 statictest static varibale, 所以才能會
能執行 static Point
{{{
import andy.Point;
public class Statictest {
static Point pb = new Point();
public static void main(String[] args) {
Statictest.pb.x = 6;
Statictest.pb.y = 10;
//System.out.println("pa.x:" + pa.x + ", pa.y" + pa.y);
}
}
}}}
{{{
[Andy@t-ap188 row]$ javac -verbose Statictest.java
[parsing started Statictest.java]
[parsing completed 31ms]
[search path for source files: .]
[search path for class files: /usr/java/jdk1.6.0_19/jre/lib/resources.jar,/usr/java/jdk1.6.0_19/jre/lib/rt.jar,/usr/java/jdk1.6.0_19/jre/lib/sunrsasign.jar,/usr/java/jdk1.6.0_19/jre/lib/jsse.jar,/usr/java/jdk1.6.0_19/jre/lib/jce.jar,/usr/java/jdk1.6.0_19/jre/lib/charsets.jar,/usr/java/jdk1.6.0_19/jre/classes,/usr/java/jdk1.6.0_19/jre/lib/ext/localedata.jar,/usr/java/jdk1.6.0_19/jre/lib/ext/sunpkcs11.jar,/usr/java/jdk1.6.0_19/jre/lib/ext/sunjce_provider.jar,/usr/java/jdk1.6.0_19/jre/lib/ext/dnsns.jar,.]
[loading ./andy/Point.class]
[loading java/lang/Object.class(java/lang:Object.class)]
[loading java/lang/String.class(java/lang:String.class)]
[checking Statictest]
[wrote Statictest.class]
[Andy@t-ap188 row]$ java -verbose Statictest
[Loaded java.security.ProtectionDomain$Key from /usr/java/jdk1.6.0_19/jre/lib/rt.jar]
[Loaded java.security.Principal from shared objects file]
[Loaded Statictest from file:/home/Andy/Desktop/working/JavaAll/JavaPractice/row/]
[Loaded andy.Point from file:/home/Andy/Desktop/working/JavaAll/JavaPractice/row/]
}}}
沒有留言:
張貼留言