What are the domains in Java? __java Programming Ideas

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.