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

};

Recommended Answers

All 3 Replies

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

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
    }

}
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.