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 6348185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:22:24+00:00 2026-05-24T21:22:24+00:00

I have two instances of the same class: Object instance1; Object instance2; I know

  • 0

I have two instances of the same class:

Object instance1;
Object instance2;

I know that the class in question has an array field. I need to compare the identityHashCode of the array field, and in some cases I expect it to be the same.

The thing is that they are always different. I am guessing that is to be expected since they are in effect two different instances.

Is there a way to compare two arrays disregarding what elements they hold?

I am using Java reflection to get the value of the arrays.

  • 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-24T21:22:24+00:00Added an answer on May 24, 2026 at 9:22 pm

    Is there a way to compare two arrays disregarding what elements they
    hold?

    Sure, you could compare the component type and the size:

    /**
     * Returns true iff two arrays of the same component type and
     * length are passed in.
     */
    public static boolean pseudoArrayEquals(Object a, Object b){
        if(a==null||b==null||!a.getClass().isArray()||!b.getClass().isArray())
            throw new IllegalArgumentException("Expected two arrays");
        return a.getClass() == b.getClass()
               && Array.getLength(a) == Array.getLength(b);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible for two instances of Object to have the same hashCode() ?
I have two classes: Action class, that has a method for executing VBScript files,
I have two instances running of same Windows Service. They check the health of
I have an odd need to open two separate instances of excel and having
I have two classes that each need an instance of each other to function.
How do I check if two instances of a class FooBar(object): __init__(self, param): self.param
I have two Maps that contain the same type of Objects: Map<String, TaskJSO> a
Suppose I have two objects $obj1 and $obj2 that are both instances of Moose
I often find I have class instances that are descendants of other class instances,
I have a manager class maintaining a list of objects. Each Object has a

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.