File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes BitSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "BitSet" Watch "BitSet" New topic
Author

BitSet

suavedeep kaur
Ranch Hand

Joined: Jun 02, 2008
Posts: 36
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 ]


Suavedeep kaur
SCJP
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41106
    
  45
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.


Ping & DNS - my free Android networking tools app
suavedeep kaur
Ranch Hand

Joined: Jun 02, 2008
Posts: 36
Actualli i am not getting this BitSet thing as 16 is passed to the BitSet object .......How is it being manipulated ???
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41106
    
  45
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

Joined: Oct 27, 2005
Posts: 19651
    
  18

It didn't; it must have been a typo.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BitSet
 
Similar Threads
Why no toBinaryString(BigInteger b)
use of bitset
ArrayList
array object reference in a method