Polymorphism is special on domain issues. I can not understand the Chinese version of the book directly called the domain, read the original English, the original is written fields, direct translation Although yes, but the problem is not a variable domain. Specifically checked what is the meaning of field in Java. Many people think of it as a range surrounded by curly braces. In fact, there is also a framework inside the--domain model, which is also called domain, domain model.
and find this article.
What is a field in Java?
A field is an attribute. A field may is a class ' s variable, an object's variable, an object ' s method ' variable, or a parameter of a function.
Class bike{
static int bikes;
int gear;
int cadence;
void Create (int newgear, int newcadence) {
bikes = bikes + 1;
Gear = Newgear;
Cadence = newcadence;}
int GetSpeed () {
int speed = gear*cadence*5*3.141;
return speed
}
}
' Bikes ' is a class ' s variable (class variable) (static field).
' Gear ' and ' cadence ' could is an object ' s variables (instance variables) (non-static fields).
' Speed ' is a object ' s variable (local variable).
' Newgear ' and ' newcadence ' are parameters of a function (parameters).
field, a field is an attribute that can be a class variable, an object variable, an object method variable, or an argument to a function. (Supplemental, class ' s variables, classes ' instance variables and static variables are called class ' s variables, generic variables, also known as class variables or data fields, translated into attributes can also, class properties, sounds not strange, from Baidu Encyclopedia).
Class bike{
static int bikes;
int gear;
int cadence;
void Create (int newgear, int newcadence) {
bikes = bikes + 1;
Gear = Newgear;
Cadence = newcadence;}
int GetSpeed () {
int speed = gear*cadence*5*3.141;
return speed
}
}
Bikes is a class variable (static domain).
Gear and Cadence are object variables (instance variables) (non-static fields).
(There is a little contradiction here, in fact, so according to Wikipedia, so bikes, gear and cadence are class variables, bikes are static variables in class variables, and gear and cadence are instance variables in class variables.) )
Speed is a variable (local variable) of an object method.
(see no, local Variable,java does not appear gobal variable, global variable, what to say the scope of the class variable and the global variable, just not called).
Newgear and Newcadence are parameters (parameters) of a function (method).
Original address: Http://www.answers.com/Q/What_is_a_field_in_java