Article View: cn.bbs.comp.lang.java
Article #12189�ʸ�����static������
From: TriTree
Date: Tue, 03 Aug 2004 02:31
Date: Tue, 03 Aug 2004 02:31
36 lines
1411 bytes
1411 bytes
class Bowl {
Bowl(int marker) {
id = marker;
System.out.println("Bowl(" + marker + ")");
}
void f(int marker) {
System.out.println("f(" + marker + ")");
}
int id;
}
class Table {
static Bowl b1 = new Bowl(1);
Table() {
System.out.println("Table()");
b2.f(1);
}
void f2(int marker) {
System.out.println("f2(" + marker + ")");
}
static Bowl b2 = new Bowl(2);
}
public class StaticInitialization {
public static void main(String[] args) {
Table.b1 = new Bowl(111);
System.out.println(Table.b1.id);
}
} ///:~
Output:
Bowl(111)
Bowl(1)
Bowl(2)
111
��������ô���Ͱ�
Ϊʲônew��111����ǰ��
--
[m[1;32m�� ��Դ:����ˮ˼Դ bbs.sjtu.edu.cn��[FROM: 202.120.59.213][m
Technical Details
Message-ID:
<4DTTL1$9OK@bbs.sjtu.edu.cn>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!nntp-server.pubsub.com!netnews.sdu.edu.cn!SJTUShow Full Headers
Complete Article Headers
X-Google-Thread: f6cb0,d0ffb2cbf3a956a,start X-Google-Attributes: gidf6cb0,public X-Google-Language: ENGLISH,GB Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!nntp-server.pubsub.com!netnews.sdu.edu.cn!SJTU From: TriTree.bbs@bbs.sjtu.edu.cn (TriTree) Newsgroups: cn.bbs.comp.lang.java Subject: �ʸ�����static������ Date: 03 Aug 2004 02:31:54 GMT Organization: ��ˮ˼Դ Message-ID: <4DTTL1$9OK@bbs.sjtu.edu.cn> Mime-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 8bit X-Filename: Java/M.1091500273.A Lines: 36