Hey guys,

my second java problem in 24 hours :)

I'm trying to call a method from another class. So basically what i'm trying to do is put the date from the main class through the method "tomorrow" so it adds 1 to the int day and returns the date to the main. I've been stuck on this for hours and have tried messing around with it but to no avail. I've highlighted my problem in bold. Thanks in advance guys.

class newDate {

    public newDate() {
        day = 1;
        month = 1;
        year = 1970;
    }

    public newDate(int _day, int _month, int _year) {
        day = _day;
        month = _month;
        year = _year;
    }
    int day;
    int month;
    int year;

    [B]public newDate tomorrow(Date futureDate) {

        futureDate.day++;// i'm adding one day on to the int day in the futureDate object.

        return this;[/B]

    }
    
}
class newTomorrow {
    public static void main(String[] args){

        [B]newDate rob = new newDate(20,10,2010);
        rob.tomorrow();


        System.out.println("The new date is " + rob.tomorrow());[/B]


    }
}

Edit to say, I want the method to return 21/10/2010 ;)

Wouldn't you know it, I spend all day messing about with the code and I get nothing. I put it on this forum and within 5 minutes of doing that, I solve the problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.