File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes need help with Bitset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "need help with Bitset" Watch "need help with Bitset" New topic

need help with Bitset

vidu mayur
Ranch Hand

Joined: Nov 13, 2003
Posts: 32
This program sorts the numbers in a string array by using a bitset provided the numbers are unique. The program keeps track of which numbers have been seen by setting bits in a bitset.
The output is printed by visiting all the elements in the bit set. The output should be like this:
In sorted order: 2 9 10 21 43 45 52 66 68 71 87
This is the problem. I am not able to give the upper limit while accessing the elements in the bitset. I have given an arbitrary number 100 for now and the program is working. Is there any way to access the last element in the bitset.

Thanks in advance
chi Lin
Ranch Hand

Joined: Aug 24, 2001
Posts: 348
try change
for (j = 0; j < 100; j++){ ... }
for (j = 0; j < sortSet.size(); j++){ ... }
vidu mayur
Ranch Hand

Joined: Nov 13, 2003
Posts: 32
It works perfectly now.
I agree. Here's the link:
subject: need help with Bitset
It's not a secret anymore!