permaculture playing cards*
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "need help with Bitset" Watch "need help with Bitset" New topic
Author

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++){ ... }
to
for (j = 0; j < sortSet.size(); j++){ ... }
vidu mayur
Ranch Hand

Joined: Nov 13, 2003
Posts: 32
Hi
It works perfectly now.
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: need help with Bitset