Hi.

It says that the operator and return statement don't work. Can someone please explain what is wrong, and why it's wrong? I don't get it.

package hello;


private class Person

{
    private string firstName, lastName;
    private Date   birthDate;
    public Person(String fN, String lN, int month, int day, int year)
    {
        firstName = fN;
        lastName  = lN;
        birthDate = new Date(month, day, year);
    }
    public boolean equals(Person theOtherPerson)
    {
        return firstName.equals(theOtherPerson.firstName) && lastName.equals(theOtherPerson.lastName) && birthDate.equals(theOtherPerson.birthDate);
    }

    public boolean equal(String fN, String lN, int month, int day, int year)
    {
        return firstName.equals(fN) && lastName.equals(lN) && birthDate.equals( new Date(month, day, year));
    }
    public String toString()
    {
        return firstName + " "  lastName + " " + birthDate.toString();
    }

};

hope this helps

import java.sql.Date;

private class Person{
    private String firstName, lastName;
    private Date   birthDate;
    public Person(String fN, String lN, int month, int day, int year)
    {
        firstName = fN;
        lastName = lN;
        birthDate = new Date(month, day, year);
    }
    public boolean equals(Person theOtherPerson)
    {
        return firstName.equals(theOtherPerson.firstName) && lastName.equals(theOtherPerson.lastName) && birthDate.equals(theOtherPerson.birthDate);
    }

    public boolean equal(String fN, String lN, int month, int day, int year)
    {
        return firstName.equals(fN) && lastName.equals(lN) && birthDate.equals( new Date(month, day, year));
    }
    public String toString()
    {
        return firstName + " " + lastName + " " + birthDate.toString();
    }

}

and you dont need semicolon at the end of the class :P
and if u want to find errors easily you should use an ide i suggest eclipse

Edited 5 Years Ago by Progr4mmer: n/a

Hi, which lines did you exactly change, and why? I don't see it:-/

ok these are the lines i changed

import java.sql.Date;//imported date

private class Person{
    private String firstName, lastName;
    private Date   birthDate;
    public Person(String fN, String lN, int month, int day, int year)
    {
        firstName = fN;
        lastName = lN;
        birthDate = new Date(month, day, year);
    }
    public boolean equals(Person theOtherPerson)
    {
        return firstName.equals(theOtherPerson.firstName) && lastName.equals(theOtherPerson.lastName) && birthDate.equals(theOtherPerson.birthDate);
    }

    public boolean equal(String fN, String lN, int month, int day, int year)
    {
        return firstName.equals(fN) && lastName.equals(lN) && birthDate.equals( new Date(month, day, year));
    }
    public String toString()
    {
        return firstName + " " + lastName + " " + birthDate.toString();//added plus between " and lastname
    }

}
This article has been dead for over six months. Start a new discussion instead.