Is it possible to add two separate arrays into one hash set?
PDB1982 0 Posting Whiz in Training
Recommended Answers
Jump to PostAre you wanting to add the two arrays as two elements, or are you wanting to add all the elements in the arrays?
For the first caseint[] a = {1,2,3}; int[] b = {4,5}; HashSet h = new HashSet(); h.add(a); h.add(b); for (Object o : h) …
Jump to PostLoo at your arraylist output in lines 8 and 16. It looks like you are putting the wrong numbers in your arrays somehow?
Anyway, that little code snippet is OK - so the problem lies somewhere else. Do you want to post more of the code?
All 6 Replies
BestJewSinceJC 700 Posting Maven
PDB1982 0 Posting Whiz in Training
PDB1982 0 Posting Whiz in Training
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
PDB1982 0 Posting Whiz in Training
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.