下载安卓APP箭头
箭头给我发消息

客服QQ:3315713922

Java类的组成(1)

作者:课课家教育     来源: http://www.kokojia.com点击数:797发布时间: 2016-01-20 15:15:31

标签: java手游开发java网站空间java课程标准

大神带你学编程,欢迎选课

  一直很喜欢一句广告词:生活就是一个七天又一个七天。而我想说的是,java应用就 是一个类又一个类。Java是面向对象的语言,对象都是由类实例化而来。一个Java应用, 不论简单还是复杂,都是由若干个Java类组成的。因此,对于初学者,先了解Java类的组 成是必要的。

Java类的组成(1)_ava手游开发_java网站空间_

  Java类的组成主要有3部分:数据成员、构造方法、方法成员。

  首先看下边的代码,是一个简单的Java类:

  package com.csst.vo;

  public class Customer {

  //1.数据成员

  private String custname;

  private String pwd;

  private Integer age;

  //2.构造方法

  public Customer() {

  }

  public Customer(String custname, String pwd) {

  this.custname = custname;

  this.pwd = pwd;

  }

  public Customer(String custname, String pwd, Integer age) {

  super();

  this.custname = custname;

  this.pwd = pwd;

  this.age = age;

  }

  //3.方法成员

  public String getCustname() {

  return custname;

  }

  public void setCustname(String custname) {

  this.custname = custname;

  }

  public String getPwd() {

  return pwd;

  }

  public void setPwd(String pwd) {

  this.pwd = pwd;

  }

  public Integer getAge() {

  return age;

  }

  public void setAge(Integer age) {

  this.age = age;

  }

  }

赞(12)
踩(4)
分享到:
华为认证网络工程师 HCIE直播课视频教程