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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:22:10+00:00 2026-05-25T17:22:10+00:00

HashSet<String[]> boog = new HashSet<String[]>(); boog.add(new String[]{a, b, c}); boog.add(new String[]{a, b, c}); boog.add(new

  • 0
HashSet<String[]> boog = new HashSet<String[]>();
boog.add(new String[]{"a", "b", "c"});
boog.add(new String[]{"a", "b", "c"});
boog.add(new String[]{"a", "b", "d"});

results in

[a, b, c]
[a, b, d]
[a, b, c]

where [a,b,c] is repeated, so the hash function is not working as expected. How would I go about overriding the Hash method for String arrays. Or for that matter, a generic array? Is there a better way to accomplish what I’m trying to do?

  • 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-25T17:22:11+00:00Added an answer on May 25, 2026 at 5:22 pm

    You can’t. arrays use the default identity-based Object.hashCode() implementation and there’s no way you can override that. Don’t use Arrays as keys in a HashMap / HashSet!

    Use a Set of Lists instead.

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

Sidebar

Related Questions

I have an interesting problem, which is a function that returns a Dictionary<String,HashSet<String>> .
My model: public class Father { Set<Son> sons = new HashSet<Son>(); String name =
Let's say I have this code in Java: HashSet<String> wordSet = new HashSet<String>(); String
Set<String> tempSet = new HashSet<String>(); for (Map.Entry<String, String> entry : map.entrySet()) { String orginalKeys
I have this code private static Set<String> myField; static { myField = new HashSet<String>();
I'm using a few functions like ICollection<ICache> caches = new HashSet<ICache>(); ICollection<T> Matches<T>(string dependentVariableName)
public class ThreadSafe implements ITaskCompletionListener { private final Set<String> taskIds = new HashSet<String>(); private
Hashtable<String, Hashtable<String, HashSet<String>>> test = new Hashtable<String, Hashtable<String, HashSet<String>>>(); test.put(1, new Hashtable<String, HashSet<String>>()); Hashtable<String,
Why does the declaration Set<Set<String>> var = new HashSet<Set<String>>(); work but the declaration Set<Set<String>>
In REPL: import collection.mutable.{ HashSet, SynchronizedSet } var myPool = new HashSet[String] with SynchronizedSet[String]

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.