自定义类的返回值咋写

  1. img

img


我这个8的返回值咋写,4怎么写
sjs;xixhhbwkqozojxbemlsxuhdbrnsp

望采纳


package com.yingkong.core.dto;

import java.util.Date;

/**
 * com.yingkong.core.dto
 * 在其中创建新文件的软件包名称
 * glt-warehouse
 * 当前项目名称
 * LBWNB
 * 当前用户的系统登录名
 */
public class MyDate {
    int year;
    int month;
    int day;
    
    
    public int getYear() {
        return year;
    }
    
    public void setYear(int year) {
        this.year = year;
    }
    
    public int getDay() {
        return day;
    }
    
    public void setDay(int day) {
        this.day = day;
    }
    
    public int getMonth() {
        return month;
    }
    
    public void setMonth(int month) {
        this.month = month;
    }
    
    public MyDate(int year, int day, int month) {
        this.year = year;
        this.day = day;
        this.month = month;
    }
    
    public MyDate() {
        this.year=1970;
        this.month=1;
        this.day=1;
    }
    
    //第四题
    public MyDate(MyDate myDate) {
        this.year=myDate.getYear();
        this.day= myDate.getDay();
        this.month= myDate.getMonth();
    }
    
    public static void main(String args[]){
    
    MyDate a=new MyDate();
//    chon重写toString方法打印当前对象
        System.out.println(a.nextDay().toString());
    }
//    第八题
    public MyDate nextDay(){
        MyDate myDate=new MyDate();
        myDate.setDay(myDate.getDay()+1);
        return  myDate;
    }
    
    @Override
    public String toString() {
        return "MyDate{" +
                "year=" + year +
                ", month=" + month +
                ", day=" + day +
                '}';
    }
}