- 简单java类,基础很重要,需要手,熟练无误的写出来
class Dept{
private long deptno;
private String dname;
private String loc;
public Dept(){// 必须提供无参构造方法;
}
public Dept(long deptno,String dname,String loc){
this.deptno = deptno;
this.dname = dname;
this.loc = loc;
}
public String getInfo(){
return "[部门信息]部门编号:" + deptno + ",部门名称:" + dname + ",部门地址:" + loc;
}
public void setDeptno(long deptno){
this.deptno = deptno;
}
public void setDname(String dname){
this.dname = dname;
}
public void setLoc(String loc){
this.loc = loc;
}
public long getDeptno(){
return this.deptno;
}
public String getDname(){
return this.dname;
}
public String getLoc(){
return this.loc;
}
}
public class HelloWorld {
public static void main(String[] args) {
Dept dept = new Dept(320302332,"技术部门","海天大厦");
String info = dept.getInfo();
System.out.println(info);
}
}
标签:loc,java,String,Dept,dname,5.12,案例,deptno,public
From: https://www.cnblogs.com/pansidong/p/17451645.html