Results 1 to 2 of 2
  1. #1
    turnergirl24 is offline Member
    Join Date
    Oct 2009
    Posts
    7
    Rep Power
    0

    Default [SOLVED] Duplicates in String Array

    I have a string array which I read from a file and I need to check for duplicates and return the number of elements which are unique. Is there a simple way of doing this?
    Last edited by turnergirl24; 11-05-2009 at 12:08 AM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    If I remember correctly, you could use the Arrays method asList(...) and use that List to create a HashSet (see HashSet's constructors). Then I believe the HashSet should contain all the unique Strings.

Similar Threads

  1. Convert Char Array to String Array
    By Mayur in forum New To Java
    Replies: 8
    Last Post: 10-12-2009, 12:41 PM
  2. FInd the no. of duplicates in an array
    By singularity in forum Advanced Java
    Replies: 3
    Last Post: 09-04-2009, 10:25 AM
  3. String array to byte array?!
    By Joe2003 in forum Advanced Java
    Replies: 5
    Last Post: 02-28-2009, 07:09 AM
  4. Duplicates
    By Gambit17 in forum New To Java
    Replies: 5
    Last Post: 11-08-2007, 10:56 AM
  5. Replies: 1
    Last Post: 08-03-2007, 11:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •