字段定义和初始化有什么区别?
我认为字段定义是整个陈述 例如 int a = 1;
并初始化分配部分 int a = 1 ;
答案 0 :(得分:2)
初始化字段
public class Example {
// initialize to false
private boolean full = false;
// initialize to 2
public static int a= 2;
}
Field Definiton:
public class Employee {
String name;
String position;
int salary;
Date hiredDate;
}