• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

BitSet

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It didn't; it must have been a typo.
 
Please do not shoot the fish in this barrel. But you can shoot at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic