shajihase
asked on
Removing duplicates from two dimensional string array
I have a two dimensional string array . I want to delete the duplicate items and form a new array with available items. How do I do that.
ASKER
Can you show me apiece of code how to do that?
Thanks
Thanks
==========================
String[] strArray = { "Test1" , "Test2" , "Test1" };
Hashtable table = new HashTable();
for( int i = 0 ; i < strArray.length ; i++ ){
table.put( strArray[i].trim() , "" );
}
Enumeration keys = table.keys();
String[] newArray = new String[ table.size() ];
for( int i = 0; keys.hasMoreElements() ; i++ ){
newArray[i] = ( String ) keys.nextElement();
}
==========================
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Use Hashtable. Put all the String values in it and then get the keys then form the string array again..