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);

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

8 Years
Discussion Span
Last Post by Bobon

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.