Java Reference
In-Depth Information
}
return desc + "]";
}
}
If we pass WhichChars the string "Testing123" we get back
[ 123Teginst]
which shows each of the characters (including the spaces) that were
used in the input string, and which, incidentally, have now been sorted
into numerical order. Notice how easy it is to iterate through all the set
bits in a bit set.
Exercise 22.2 : The WhichChars class has a problem marking characters
near the top of the Unicode range because the high character values will
leave many unused bits in the lower ranges. Use a HashSet to solve this
problem by storing Character objects for each character seen.
Exercise 22.3 : Now use a HashMap to store a BitSet object for each dif-
ferent top byte (high 8 bits) encountered in the input string, with each
BitSet storing the low bytes that have been seen with the particular high
byte.
 
Search WWH ::




Custom Search