cancel
Showing results for 
Search instead for 
Did you mean: 

UDF - remove dulicates

Former Member
0 Kudos

Hi, I need to remove duplicates from my String[] array. Any ideas?

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member91687
Active Contributor
0 Kudos

Hi Rune,

Loop through your array values, and compare the ith value and i+1 value and set a flag if it is a duplicate value is found, write out the resultset based on the condition check of the flag.

Something like this.

for(int i=0 ; i< a.length ; i++)

{

for(int j=1;j< a.length; j++)

{

if( a<i> == a[j])

set flag=x; // initialize the flag to some value inside the first for loop

.

.

.

}

}

Try this logic with the right condition check to set the flag value, it will work.

Regards,

Chandra

Former Member
0 Kudos

HashSet hs=new HashSet();

for(int i=0;i<Str.length;i++)

hs.add(Str<b>[i</b>]);

String result[]=new String[hs.size()];

for(int j=0;j<result.length;j++)

result[j]=(String)hs.get(j);

try this...

Regards,

Jai Shankar