wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes how to compare this? please help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to compare this? please help" Watch "how to compare this? please help" New topic
Author

how to compare this? please help

catherine matthews
Ranch Hand

Joined: Jan 22, 2006
Posts: 78
i need to see the content of 2 arrays
if there is repitition i need to take only one occurance...
Lets say i have 2 arrays arr and arr2 and their content is as below....
arr[0]=abc arr2[0]=123
arr[1]=cde arr2[1]=102
arr[2]=efg arr2[2]=789
arr[3]=abc arr2[3]=123
arr2[0]=abc arr2[4]=456

i need need to count how mnay times an element of arr is being used by different arr2.

so for this set of example... i need to eliminate arr2[3] because it is the same as arr2[0]...
thus the elememt in arr would have counts like this
abc = 2
cde=1
efg=1

how to i go about... please help me.... so far this is what i have done....
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
I'm sorry I don't fully understand your question. It sounds like you may want to make use of a java.util.Set though. A Set does not allow duplicate entries, if you were to dump the contents of your array into a Set you would eliminate any duplicates presuming the contents are not primitives and have appropriate equals() methods.

Are you attempting to merge the arrays at all?
 
jQuery in Action, 2nd edition
 
subject: how to compare this? please help
 
Similar Threads
How to refresh a StringBuffer object for creating a HashMap object
Adding elements of two arrays
2 dimensional array problem
Output Not understand!!!
Arrays