private String[] removeDuplicates(String[] list){
  if ((list == null) || (list.length < 2))   return list;
  String[] list2=new String[list.length];
  int count=0;
  for (int i=0; i < list.length; i++) {
    boolean duplicate=false;
    String element=list[i];
    for (int j=0; j < count; j++) {
      if (((element == null) && (list2[j] == null)) || ((element != null) && (element.equals(list2[j])))) {
        duplicate=true;
        break;
      }
    }
    if (duplicate)     continue;
    list2[count++]=list[i];
  }
  if (count == list2.length)   return list2;
  String[] tmp=new String[count];
  System.arraycopy(list2,0,tmp,0,count);
  return tmp;
}

private String [ ] removeDuplicates ( String [ ] list ) { if ( ( list == null ) || ( list . length < 2 ) ) return list ; String [ ] list2 = new String [ list . length ] ; int count = 0 ; for ( int i = 0 ; i < list . length ; i ++ ) { boolean duplicate = false ; String element = list [ i ] ; for ( int j = 0 ; j < count ; j ++ ) { if ( ( ( element == null ) && ( list2 [ j ] == null ) ) || ( ( element != null ) && ( element . equals ( list2 [ j ] ) ) ) ) { duplicate = true ; break ; } } if ( duplicate ) continue ; list2 [ count ++ ] = list [ i ] ; } if ( count == list2 . length ) return list2 ; String [ ] tmp = new String [ count ] ; System . arraycopy ( list2 , 0 , tmp , 0 , count ) ; return tmp ; }
removes duplicates from a string array , keeps only first occurence of each element . does not destroy order of elements ; can handle nulls . uses a very efficient o ( n ^ 2 ) algorithm = )
