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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:05:43+00:00 2026-06-14T01:05:43+00:00

For example, I have two object, which a the class, Person. Person A: User_name:n1

  • 0

For example, I have two object, which a the class, Person.

Person A:
User_name:n1
Password:1234
Email:n1@email.com

Person B:
User_name:n1
Password:1234
Email:n1@email.com

Because both Person A and Person B have same values, so, I would like to write my own isValueEqual function. first, I want to compare their classes, then, I campare their value one by one to check whether it is equal. I think this way is super time consuming. So, I think is this reliable to make it become a JSON string, and use the md5 to hash them, and compare the hash only. So, is this a better approach for comparing their value? Thanks.

  • 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-14T01:05:43+00:00Added an answer on June 14, 2026 at 1:05 am

    To explain what Jim Garrison explains in this comment in more details, just consider the work necessary to implement equals by comparing the fields, and the work necessary to implement it by generating a hash and comparing the hashes. Let’s take your example, with A and B differing only by the last letter of their email (which is the worst case).

    First method:

    • iterate through all the name characters and compare them
    • iterate through all the password characters and compare them
    • iterate through all the email characters and compare them.

    Second method:

    • create two new StringBuilders
    • iterate through all the name characters to fill the name in the JSON strings, and append them to the StringBuilder, surrounded by quotes, with special characters escaped, etc.
    • iterate through all the password characters to fill the password in the JSON strings, and append them to the StringBuilder, surrounded by quotes, with special characters escaped, etc.
    • iterate through all the email characters to fill the email in the JSON strings, and append them to the StringBuilder, surrounded by quotes, with special characters escaped, etc.
    • transform the StringBuilders to Strings
    • transform the Strings to byte arrays
    • apply a complex cryptographic function to both byte arrays
    • iterate through each byte array and compare the bytes.

    Note that if the persons differ by the first character or the length of their name, the first method stops immediately, whereas the second one must do every step.

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

Sidebar

Related Questions

We have two A records pointing to same public IP address as: www.example.com IN
I have two classes, one which inherits the other, for example:- public class A
For example I have SomeClass class which implements ISomeInterface interface with two properties Prop1
I have two websites: http://example.com http://example.com/sub I have a page, let's say: http://example.com/sub/page1 Is
I have two html pages on my webserver www.example.com/desktop.html www.example.com/mobile.html In principle the content
A have two entities. For example timing settings and orders. @Entity public class TimingSettings{
In the following example I have two years worth of data denoted by data_2007
I have two example. First is true and second is wrong. It's just different
Let's take an example where we have two entities: ServiceProvider and TelephoneNumber . The
I have two virtual hosts on windows(for example: test1.dev and test2.dev). But it always

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.