Java成員變數與屬性的區別,簡單最易懂的解釋!!!

來源:互聯網
上載者:User

標籤:定義   string   oid   成員變數   get   return   原理   首字母   name   

例一:一個Student pojo類: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;}}成員變數:   name  和  age  屬性:屬性的官方定義:SUN官方定義為屬性是指get或者set方法名 去掉get或者set後,把剩餘的部分首字母改為小寫後,即為這個類的屬性。在本例中:屬性是指:name  和   age  可以再舉一個例子:例二:public class student{  public String getName(){    return " my name is dark_passion !";  }}成員變數:  無屬性:name ;以上就是 java成員變數和屬性的區別,理解原理才是最好的學習!

 

Java成員變數與屬性的區別,簡單最易懂的解釋!!!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.