The difference between Java member variables and attributes is simple and easy to understand !!!, Java Variables

Source: Internet
Author: User

The difference between Java member variables and attributes is simple and easy to understand !!!, Java Variables

Example 1: A Student pojo class: public class Student {private String name; private int age; public String getName () {return this. name;} public void setName (String name) {this. name = name;} public int getAge () {return this. age;} public void setAge (int age) {this. age = age ;}} member variables: name and age attributes: the official definition of the property: SUN officially defines the property as "get" or "set Method" after removing the get or set method name, change the first letter of the remaining part to lowercase, that is, the attribute of this class. In this example, attributes refer to name and age. For example, public class student {public String getName () {return "my name is dark_passion! ";}} Member variable: No attribute: name; The above is the difference between java member variables and attributes. Understanding the principle is the best learning!

 

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.