Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6846151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:35:13+00:00 2026-05-27T00:35:13+00:00

I am currently working on a simple line program in java. There will be

  • 0

I am currently working on a simple line program in java. There will be no actual GUI, so it is completely text based.

We are required to have a point class and a line class that includes to point objects.

The problem I encountered was involving the equals method for my point class. Considering each point only has two POSITIVE int values, an x and a y, and I’m having issues here, I’m worried I will have problems when I have to compare lines, which will involve comparing the points, the int width and the string color.

This is what the code for my equals method for my point class looks.

@Override
public boolean equals(Point that) {
    if(this==that)
        return true;
    //if
    if(this.x==that.getX() && this.y==that.getY())
        return true;
    return false;
}

Any and all help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:35:14+00:00Added an answer on May 27, 2026 at 12:35 am

    The signature needs to contain Object, not Point. You then need the obvious checks to make sure the object is in fact a point and it’s non-null.

    Apart from that, as you’ve put it there I don’t see any problem with the method, it’s reflexive, symmetric, consistent and transitive as far as I can make out. If your class used doubles then I’d say put a delta value in when comparing them – but obviously with ints that’s not a problem.

    The indirect problem though is that you really should override hashcode as well to behave in the same way, otherwise you could run into strange issues when adding your points to collections that make use of hashcode() (by contract they’re expected to compare the objects in the same way.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on a simple Silverlight app that will allow people to
I'm working on a relatively simple website with (currently) a single resource. I have
I'm currently working on a small utility program that only requires a command line
I am currently working on some simple custom allocators in c++ which generally works
I am currently working on a simple web application through Google App engine using
I`m currently working out the design for simple graphic editor, who support trivial operations
I'm currently working on a reasonably simple MVC app which allows the user to
I'm currently working on a small project with OCaml; a simple mathematical expression simplifier.
Currently working in the deployment of an OFBiz based ERP, we've come to the
Am working on a program that will allow a graph of nodes to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.