The differences between Java field, Property,attribute,variable and GetField and Getdeclaredfield

Source: Internet
Author: User

The difference between field, property, attribute,variable in Java

Field: is defined as the fields used to hold the data

Property:property is used to describe the characteristics of a class, so the property is broader than field meaning, because the features contain more extensive aspects, a data can represent a certain aspect of the characteristics, but not all of the characteristics are the data you want, It may be a description of an attribute of the class itself.

attribute: no this guy. Don't look at it.

Variable: Variables are variables that we normally see.

All in all: if you want to get a field in a data model by reflection, it's not much of a relationship with field.

GetField: Gets all the public fields of a class (all fields that contain the inherited class)

Getdeclaredfield: Gets the field of the current class (all fields that contain the public,protected,private adornment, and does not contain the fields of the class to which it inherits)

The method to get the reflection field is to use Getdeclaredfield;

The differences between Java field, Property,attribute,variable and GetField and Getdeclaredfield

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.