Domain in java
The so-called domain is actually the translation of "field", which is what we often call fields, or Attributes. Such as class fields (properties), local and global.
field, a field is an attribute, which can be a class variable, an object variable, an object method variable or a function parameter.
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, according to the encyclopedia, bikes, gear and cadence are all class variables. bikes is a static variable in the class variable, and gear and cadence are class variables. Instance variable.)
speed is a variable (local variable) of the object method.
(See, local variable, gobal variable, global variable does not appear in Java. If I want to say, the scope of class variables is the same as global variables, but they are not called that).
newGear and newCadence are parameters (parameters) of functions (methods).
Recommended learning: Java video tutorial
The above is the detailed content of What is the java domain?. For more information, please follow other related articles on the PHP Chinese website!