public class Test
{
public static Test1 t = new Test1();
public static int a = 0;
public static int b;
public static void main(String[] arg)
{
System.out.println(Test.a);
System.out.println(Test.b);
}
}
class Test1
{
public Test1()
{
Test.a++;
Test.b++;
}
}
public class A
{
public static int b = B.a;
public static A plus =new A("A");
public static final int finalInt = (int)(Math.random()*100);
public static B p = new B("A");
public static final String finalStr = "finalStr";
public static final Integer finalInteger = new Integer(10);
public static int a = 1;
public static B c = null;
public A(String from)
{
System.out.println("----------- begin A::A ----------------");
System.out.println("A::A, from="+from);
System.out.println("A::A, A.b="+A.b);
System.out.println("A::A, A.finalInt="+A.finalInt);
System.out.println("A::A, B.a="+B.a);
System.out.println("A::A, B.plus="+B.plus);
System.out.println("----------- end A::A ----------------");
}
public static void main(String[] arg)
{
System.out.println("main, A.b="+A.b);
System.out.println("main, B.t="+B.t);
System.out.println("main, C.a="+C.a);
}
}
class B
{
public static int t = A.a;
public static A plus = new A("B");
public static int a = 1;
public B(String from)
{
System.out.println("----------- begin B::B ----------------");
System.out.println("B::B, from="+from);
System.out.println("B::B, B.a="+B.a);
System.out.println("B::B, A.a="+A.a);
System.out.println("B::B, A.p="+A.p);
System.out.println("B::B, A.plus="+A.plus);
System.out.println("B::B, A.finalInt="+A.finalInt);
System.out.println("B::B, A.finalInteger="+A.finalInteger);
System.out.println("B::B, A.finalStr="+A.finalStr);
System.out.println("----------- end B::B ----------------");
}
}
class C
{
public static final A a = new A("C");
}
----------- begin A::A ---------------- A::A, from=B A::A, A.b=0 A::A, A.finalInt=0 A::A, B.a=0 A::A, B.plus=null ----------- end A::A ---------------- ----------- begin A::A ---------------- A::A, from=A A::A, A.b=1 A::A, A.finalInt=0 A::A, B.a=1 A::A, B.plus=A@a90653 ----------- end A::A ---------------- ----------- begin B::B ---------------- B::B, from=A B::B, B.a=1 B::B, A.a=0 B::B, A.p=null B::B, A.plus=A@1fb8ee3 B::B, A.finalInt=61 B::B, A.finalInteger=null B::B, A.finalStr=finalStr ----------- end B::B ---------------- main, A.b=1 main, B.t=0 ----------- begin A::A ---------------- A::A, from=C A::A, A.b=1 A::A, A.finalInt=61 A::A, B.a=1 A::A, B.plus=A@a90653 ----------- end A::A ---------------- main, C.a=A@61de33
class Bowl {
Bowl(int marker) {
print("Bowl(" + marker + ")");
}
void f1(int marker) {
print("f1(" + marker + ")");
}
}
class Table {
static Bowl bowl1 = new Bowl(1);
Table() {
print("Table()");
bowl2.f1(1);
}
void f2(int marker) {
print("f2(" + marker + ")");
}
static Bowl bowl2 = new Bowl(2);
}
class Cupboard {
Bowl bowl3 = new Bowl(3);
static Bowl bowl4 = new Bowl(4);
Cupboard() {
print("Cupboard()");
bowl4.f1(2);
}
void f3(int marker) {
print("f3(" + marker + ")");
}
static Bowl bowl5 = new Bowl(5);
}
public class StaticInitialization {
public static void main(String[] args) {
print("Creating new Cupboard() in main");
new Cupboard();
print("Creating new Cupboard() in main");
new Cupboard();
table.f2(1);
cupboard.f3(1);
}
static Table table = new Table();
static Cupboard cupboard = new Cupboard();
}
Bowl(1) Bowl(2) Table() f1(1) Bowl(4) Bowl(5) Bowl(3) Cupboard() f1(2) Creating new Cupboard() in main Bowl(3) Cupboard() f1(2) Creating new Cupboard() in main Bowl(3) Cupboard() f1(2) f2(1) f3(1)
class Cup {
Cup(int marker) {
print("Cup(" + marker + ")");
}
void f(int marker) {
print("f(" + marker + ")");
}
}
class Cups {
static Cup cup1;
static Cup cup2;
static {
cup1 = new Cup(1);
cup2 = new Cup(2);
}
Cups() {
print("Cups()");
}
}
public class ExplicitStatic {
public static void main(String[] args) {
print("Inside main()");
Cups.cup1.f(99); // (1)
}
// static Cups cups1 = new Cups(); // (2)
// static Cups cups2 = new Cups(); // (2)
}
Inside main() Cup(1) Cup(2) f(99)
class Mug {
Mug(int marker) {
print("Mug(" + marker + ")");
}
void f(int marker) {
print("f(" + marker + ")");
}
}
public class Mugs {
Mug mug1;
Mug mug2;
{
mug1 = new Mug(1);
mug2 = new Mug(2);
print("mug1 & mug2 initialized");
}
Mugs() {
print("Mugs()");
}
Mugs(int i) {
print("Mugs(int)");
}
public static void main(String[] args) {
print("Inside main()");
new Mugs();
print("new Mugs() completed");
new Mugs(1);
print("new Mugs(1) completed");
}
}
Inside main() Mug(1) Mug(2) mug1 & mug2 initialized Mugs() new Mugs() completed Mug(1) Mug(2) mug1 & mug2 initialized Mugs(int) new Mugs(1) completed
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有