Java類的組成
57 2017-05-23
Java類的組成
我想說的是,Java運用就是一個類又一個類。Java是面向目標的言語,目標都是由類實例化而來。一個Java運用,不管簡略仍是雜亂,都是由若干個Java類組成的。因而,關于初學者,先知道Java類的組成是必要的。
Java類的組成首要有3有些:數(shù)據(jù)成員、結構辦法、辦法成員。
首要看下邊的代碼,是一個簡略的Java類:
packagecom.csst.vo;
publicclassCustomer{
//1.數(shù)據(jù)成員
privateStringcustname;
privateStringpwd;
privateIntegerage;
//2.結構辦法
publicCustomer(){
}
publicCustomer(Stringcustname,Stringpwd){
this.custname=custname;
this.pwd=pwd;
}
publicCustomer(Stringcustname,Stringpwd,Integerage){
super();
this.custname=custname;
this.pwd=pwd;
this.age=age;
}
//3.辦法成員
publicStringgetCustname(){
returncustname;
}
publicvoidsetCustname(Stringcustname){
this.custname=custname;
}
publicStringgetPwd(){
returnpwd;
}
publicvoidsetPwd(Stringpwd){
this.pwd=pwd;
}
publicIntegergetAge(){
returnage;
}
publicvoidsetAge(Integerage){
this.age=age;
}
掃一掃
獲取更多福利
獵學網(wǎng)企業(yè)微信
獵學網(wǎng)訂閱號
獵學網(wǎng)服務號