dustin ledezma
dustin ledezma

Reputation: 635

Is there a std::bitset equivalent (or similar) in Java?

I am looking for a c++ std::bitset equivalent or a similar functionality implementation in Java (1.6 specifically). I tried java.util.BitSet but I am finding that it is not quite similar.

The operations I need are the usual bitwise operations such as AND, OR, etc. If possible, I'd like to be able to set the length of the bitset dynamically (which is unsupported in std::bitset). Can anyone provide a recommendation? Thanks.

Upvotes: 0

Views: 1165

Answers (2)

Voo
Voo

Reputation: 30206

I don't see what problem you'd have with the normal Bitset class.

The bitset is dynamically grown if necessary (with length() returning the pos of the higehst one bit), so that's basically a fool proof solution.

Upvotes: 4

apprentice
apprentice

Reputation: 64

This can help you?

http://download.oracle.com/javase/tutorial/java/nutsandbolts/op3.html

i don't know how std::bitset work, but you can use bitwise operator in Java and C++ similary

Upvotes: 1

Related Questions