本帖最后由 丁晓宇 于 2012-2-22 18:56 编辑
- //定义类的三个构造方法
- //无参
- public User() { }
- //为用户名赋值,
- public User(String name) {
- this.name = name;
- }
- //为用户名和口令赋值
- public User(String name, String password) {
- this.name = name;
- this.password = password;
- }
- // 让用户名也有
- public User(String name, String password, int number) {
- this.name = name;
- this.password = password;
- this.number = number;
- }
复制代码 |