aspose file tools*
The moose likes Beginning Java and the fly likes how to get duplicates? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to get duplicates?" Watch "how to get duplicates?" New topic
Author

how to get duplicates?

catherine matthews
Ranch Hand

Joined: Jan 22, 2006
Posts: 78
here is my algorithm to find duplicates . the arrays statement and statement2 has the same elemnts.... I compare them if it occurs more then once i need to indicate....



I do not know where i went wrong.... please help... i dont get any output for the set of input like this....
import javax.swing.*;
import java.util.regex.*;
import java.util.*
import java.awt.event.*;;
import java.util.regex.*;
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Look carefully at what sk and s1 indicate.
[ July 15, 2006: Message edited by: Keith Lynn ]
catherine matthews
Ranch Hand

Joined: Jan 22, 2006
Posts: 78
bingo
they are both String... so i would need to use equals
rather than ==
i got the answer when i did it
thanks ya!!
Adam Nace
Ranch Hand

Joined: Jul 17, 2006
Posts: 117
Originally posted by catherine matthews:
bingo
they are both String... so i would need to use equals
rather than ==
i got the answer when i did it
thanks ya!!


Not just in the case of String, either. Don't forget that ALL objects should be compared for equivalence using Object.equals, unless the EXACT reference equality is what you want.

Also, I wondered about the condition statement (duplicates > 1). Shouldn't this have been (duplicates >= 1) ?

- Adam
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get duplicates?