Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BitSet

 
suavedeep kaur
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am not getting how BitSet is working as the output is not what i was expecting .............so please can someone explain me whats the logic ?

import java.util.*;


[ July 26, 2008: Message edited by: suavedeep kaur ]
[ July 26, 2008: Message edited by: suavedeep kaur ]
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What output did you get? What did you expect?

Also, please UseCodeTags when posting code of any length. You can edit your post to add them by clicking the little paper-and-pencil ()icon.
 
suavedeep kaur
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actualli i am not getting this BitSet thing as 16 is passed to the BitSet object .......How is it being manipulated ???
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
16 is just the initial size; it has no impact on the values stored in the BitSet.

What do you mean by "how is it manipulated"? You manipulate a BitSet by calling its set, clear, flip, and, or and xor methods, like your code is doing.

Note that the and, or and xor calls change the BitSet they're applied to - bits2 in this case. And since after the "or" call both sets are identical, the xor call will produce an empty set.

Initial pattern in bits2: {1,2,3,4,5,6,7,8,9,11,12,13,14}

That's very strange, by the way. How did the 5 get in there?
 
Rob Spoor
Sheriff
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It didn't; it must have been a typo.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic