• Post Reply Bookmark Topic Watch Topic
  • New Topic

array  RSS feed

 
kalai sundar
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an array of strings with some repeated elements, and I want to count the redundancy, how do I manage that?

for eg;
6,4,2,1,3,5
6,4,2,1,3,5
6,4,2,1,3,5
6,4,2,1,3,5

i want ths output as 6,4,1,3,5

can nayone hepl me

kalai
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you have 4 strings that are all identical? Could you explain how the "redundancy" of that is "6,4,1,3,5"? I'm not sure what redundancy means in the context of strings.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Ulf said,
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think one string is "6,4,1,3,5" and you want to eliminate other identical strings?

You can put them into a Set one at a time. The Set will ignore or discard duplicates. Then take them back out of the Set with toArray
 
kalai sundar
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank u Stan James

i got solution for that, i am used set to remove the duplication.


with regards
kalai
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!