摘要: 示例程序(一)//使用静态字段 1 public class Checkclassnumber { 2 static int num = 0; 3 { 4 num++; 5 } 6 public static void main(String[] ar... 阅读全文
posted @ 2015-10-17 10:23 卫平公 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 1.示例程序 1 public class Example 2 { 3 int x = 3;//类的实例变量,初始化值为3 4 static int y = 4;//类的静态变量,初始化值为4 5 public static void method()//静态方法 6 { 7 ... 阅读全文
posted @ 2015-10-17 10:19 卫平公 阅读(2880) 评论(0) 推荐(0) 编辑
摘要: 1.示例程序 1 class Root 2 { 3 static{ 4 System.out.println("Root的静态初始化块"); 5 } 6 { 7 System.out.println("Root的普通初始化块"); 8 ... 阅读全文
posted @ 2015-10-17 10:17 卫平公 阅读(1283) 评论(0) 推荐(0) 编辑
摘要: 1.示例程序: 1 class InitializeBlockClass 2 { 3 { 4 field=200; 5 } 6 public int field=100; 7 public InitializeBlockClass(int value)... 阅读全文
posted @ 2015-10-17 10:16 卫平公 阅读(289) 评论(0) 推荐(0) 编辑