实例初始值设定项块类似于构造函数。每个对象都会调用一次,可用于设置实例变量的初始值。请参见下面的示例。
public class Tester { public int a; { a = 10; } public static void main(String[] args) { System.out.println(new Tester().a); } }It will print the value of an as 10.
public class Tester { public int a; { a = 10; } public static void main(String[] args) { System.out.println(new Tester().a); } }
It will print the value of an as 10.
友情链接: json在线解析 通晓查询 糯晒黄历 姓名打分