JAVA 关于javabean

来源:百度知道 编辑:UC知道 时间:2024/06/08 12:09:16
package com.haha.vo;
import java.util.HashSet;
import java.util.Set;

public class Dept {
private int deptid;
private String deptname;
private String deptno;
private String leader;

//与分页相关的字段
private int totalPages;//总页数
private int pageSize;//每页记录数
private int currentPage=1;//当前页

public int getCurrentPage() {
return currentPage;
}

public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;

}

public int getTotalPages() {
return totalPages;
}

public void setTotalPages(int totalPages) {
this.totalPages = totalPages;
}

public int getPageSize() {
return pageSize;
}

public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
private Set students =new HashSet();
public Dept(int deptid) {
super();
this.deptid = deptid;
}
public D

楼主把你的问题发到这个邮件里面去!
menglinchong@163.com
把整个程序也都发过去,要不你的问题里面涉及到其实的类的关系,你这样问我们看不出来问题的实质在哪!

super 是调用父类的构造方法
this 是指本身这个类的一个特殊对象,可以理解成一个对象

this通常指代当前对象,通过this可以访问当前对象的属性和方法(包括构造方法)。
super通常指代父类,通过super可以访问父类的方法(包括构造方法)和属性。

super是调用父类里的某些方法的引用。你的JavaBean没有继承自什么自己的类, 默认继承自Object类。 super();的意思, 就是调用父类构造函数。 在你这里, 没有这个必要。

this是引用自身对象的属性和方法。 比如你的:
public void setStudents(Set students) {
this.students = students;
}
方法, 里面有两个students变量, 为了区分, 所以加上了this, this.students就是说, 自身对象的属性。 而不加this的stutdents, 就是传递过来的实参。

super this 用来调用父类的方法。
getter()用来取值,setter()用来设置值。