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

  • SEARCH
  • Home
  • 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 8842239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:54:31+00:00 2026-06-14T10:54:31+00:00

I have an array in Java. Each entry of array is a pair of

  • 0

I have an array in Java. Each entry of array is a pair of numbers (x and y coordinates).

Technically, an example of my array is:

setOfPoints = {(1,2), (3,4), (5,6), (1,9), (7,4)}

How can I search that list and check whether (3,4) is part of that set?

Ideally, I would like to do a Java function isCoordinateInSet((3,4), setOfPoints). I would also like to avoid using for loops that could potentially increase the time of operation. I am thinking of using Java Maps fpr this task. What do you think?

I am not following the Java syntax above, but I described it as so, to better explain what I want to do.

I would appreciate your input.

Thank you.

  • 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-06-14T10:54:32+00:00Added an answer on June 14, 2026 at 10:54 am
    public class Point{
    
        private int x,y;
    
        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    
        public int getX() {
            return x;
        }
    
        public void setX(int x) {
            this.x = x;
        }
    
        public int getY() {
            return y;
        }
    
        public void setY(int y) {
            this.y = y;
        }
    
        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
    
            Point point = (Point) o;
    
            if (x != point.x) return false;
            if (y != point.y) return false;
    
            return true;
        }
    
        @Override 
        public int hashCode() {
            int result = x;
            result = 31 * result + y;
            return result;
        }
    }
    

        Set<Point> points = new HashSet<>();
        points.add(new Point(3,4));
        points.add(new Point(5,6));
        points.add(new Point(1,2));
        points.add(new Point(3,5));
    
        System.out.println(points.contains(new Point(3,4)));
        System.out.println(points.contains(new Point(1,2)));
        System.out.println(points.contains(new Point(2,4)));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of java objects. Each object stores two longs that define
Suppose that I have a 2D array (matrix) in Java like this... int[][] MyMat
I have an array, for example (in Java) int[] a = new int[N]; I
I have two array list. Each has list of Objects of type User. The
Using java for Android development. I have an array that stores image resources. The
I have a float array in java and want to convert each element to
In a Java program, I have an array of objects. Each object has a
I have two array list. Each has list of Objects of type Employee. The
I have two identical array lists in java each having a string value and
I have two array list. Each has list of Objects of type Employee. The

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.