I saw the code below from java tutorial oracle. In order to count the number of words between doorbell
(inclusive) and pickle
(inclusive), the author added \0
after the word pickle
. I understand that the effect of adding \0
after pickle
, is that the word pickle
is now included as part of the subset. But my question is, why use \0
? Could someone please help me out? Thanks in advance for any help!
SortedSet<String> dictionary = new TreeSet<>(entire collection of words from a dictionary);
int count = dictionary.subSet("doorbell", "pickle\0").size();
System.out.println(count);
Edit:
Also, what happen if the variable dictionary
is a reference to SortedSet? what should I do now if I want to include the highEndPoint?