求java大佬解决(求java大佬解答)
求java大佬解答
刚完成--
User
import java.util.Date;
public class User {
private int id;
private String userName;
private String pwd;
private Date birthday;
private Date createDateTime;
private Date ModifyDateTime;
public User(int id, String userName, String pwd, Date birthday) {
this.id = id;
this.userName = userName;
this.pwd = pwd;
this.birthday = birthday;
this.createDateTime = new Date();
this.ModifyDateTime = new Date();
}
@Override
public String toString() {
return "ID:" + id + " 创建时间: " + createDateTime.toString();
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public Date getCreateDateTime() {
return createDateTime;
}
public void setCreateDateTime(Date createDateTime) {
this.createDateTime = createDateTime;
}
public Date getModifyDateTime() {
return ModifyDateTime;
}
public void setModifyDateTime(Date modifyDateTime) {
ModifyDateTime = modifyDateTime;
}
}TestUser
import java.util.Calendar;
import java.util.Date;
public class UserTest {
public static void main(String[] args){
User user1 = new User(1,"a","a",new Date(2000,1,1));
User user2 = new User(2,"b","b",new Date(2000,2,2));
User user3 = new User(3,"c","c",new Date(2000,3,3));
User user4 = new User(4,"d","d",new Date(2000,4,4));
User[] users = new User[4];
users[0] = user1;
users[1] = user2;
users[2] = user3;
users[3] = user4;
User oldestUser = user1; // 假设user1最老
for (User user : users){
if (oldestUser.getCreateDateTime().after(user.getCreateDateTime())){
oldestUser = user;
}
}
System.out.println("创建时间最早的user对象: " + oldestUser);
UserTest userTest = new UserTest();
userTest.getDate(users);
}
public void randomUser(User[] users){
for (int i = 0;i < 2;i++){
System.out.println(users[(int)(Math.random() * 4)]); // 可能两个一样的
}
}
public void getMaxAge(User[] users){
User oldestUser = users[0]; // 初始最老者
for (User user : users){
if (oldestUser.getBirthday().after(user.getBirthday())){
oldestUser = user;
}
}
System.out.println("年龄最大的用户信息: " + oldestUser);
}
public void getCreateDate(User[] users){
Date date = new Date(2017,1,1);
System.out.println("所有2017-1-1日之后创建的用户信息:");
for (User user : users){
if (user.getCreateDateTime().after(date)){
System.out.println(user);
}
}
}
public void containsTest(User[] users){
System.out.println("密码中含有@符号的所有用户信息:");
for (User user : users){
if (user.getPwd().indexOf("@") > 0){
System.out.println(user);
}
}
}
public void getDate(User[] users){
Calendar now = Calendar.getInstance();
for (User user : users){
Calendar birthday = Calendar.getInstance();
birthday.setTime(user.getBirthday());
int offset =birthday.get(Calendar.DAY_OF_YEAR) - now.get(Calendar.DAY_OF_YEAR);
if (offset == 0){
System.out.println("用户" + user.getId() + "今天生日");
} else if(offset > 0){
System.out.println("用户" + user.getId() + "距离生日还有" + offset + "天");
} else {
System.out.println("用户" + user.getId() + "生日已经过了");
}
}
}
public void compareDate(User[] users){
User max = users[0];// 最大
User min = users[0];// 最小
for (User user : users){
if (max.getBirthday().after(user.getBirthday())){
max = user;
}
if (min.getBirthday().before(user.getBirthday())){
min = user;
} // 可能是同一个人
}
System.out.println("年龄最小的和年龄最大的用户之间差了 " + (min.getBirthday().getYear() - max.getBirthday().getYear()) + "岁");
}
}
如图所示的问题,求JAVA大佬帮忙解决
利用windows Media Create Tool升级(可自定义是否保留个人配置及文件)
java问题 求大哥快点解决?为什么这个类是对象的对象this可以直接用add()方法,将jb放入到内容面板上?
JFrame是从Frame继承过来的,Frame有这个方法,因此Jframe也可以,但一般都会getContentPane()后再放